I was writing up the supported platforms for my PCL recently, one of which is other PCLs. I was confused if my library (which targets .NET Framework 4.5 and Windows/Phone 8.1) can be used in .NET Core projects as well.
我最近为我的PCL编写了支持的平台,其中一个是其他PCL。如果我的库(针对.NET Framework 4.5和Windows / Phone 8.1)也可以在.NET Core项目中使用,我感到很困惑。
As I understand it, PCLs allow you to share code across multiple platforms without recompilation, while .NET Core does that as well. The only difference is that .NET Core targets a few more platforms, i.e. OS X and Linux, and is open source.
据我所知,PCL允许您跨多个平台共享代码而无需重新编译,而.NET Core也可以这样做。唯一的区别是.NET Core面向更多的平台,即OS X和Linux,并且是开源的。
So essentially, I don't see how .NET Core is any different than Microsoft rebranding the PCL and saying "PAY ATTENTION we're going open source and targeting non-Windows platforms!"
基本上,我看不出.NET Core与微软重塑PCL有什么不同,并说“请注意我们要开源并针对非Windows平台!”
So the bottom line is, are PCLs compatible with .NET Core, and vice versa? What's the difference between them?
那么底线是PCL与.NET Core兼容,反之亦然?它们之间有什么区别?
2 个解决方案
#1
14
There is a beautiful article series about it which solved my questions around it ...
有一篇关于它的精美文章系列解决了我的问题......
https://oren.codes/2015/06/16/demystifying-pcls-net-core-dnx-and-uwp-redux/ https://oren.codes/2015/07/29/targeting-net-core/
.Net Core has all his libraries (e.g. System.IO) in separate NuGet packages (each of them available for the SDKs DNX, UWP and .Net 4.6). Third party libraries target dnxcore50
(DNX) or uap10.0
(UWP) if they access the platform natively or rely on their features. If they do not access the platform but only rely on other packages, they should target dotnet
.
.Net Core将他的所有库(例如System.IO)放在单独的NuGet包中(每个包都可用于SDK DNX,UWP和.Net 4.6)。如果第三方库本机访问平台或依赖于其功能,则第三方库将以dnxcore50(DNX)或uap10.0(UWP)为目标。如果他们不访问平台但只依赖其他软件包,他们应该以dotnet为目标。
dotnet
effectively means: I am compatible with any platform which satisfy my dependencies (your library XYZ "dotnet" which uses System.Reflection dnxcore5+net45
could not be used by a UWP uap10.0
app). This effectively ends the combinatoric nightmare of the platforms. The previous target combination dnxcore5+net45
created an intersection between the platforms libraries and each addition would make the situation even worse. dotnet
on the other side does not restrict the library on a target but instead forwards this restriction decision to its dependencies (where suddenly new restrictions like the famous unicorn
platform can show up).
dotnet有效意味着:我与任何满足我的依赖关系的平台兼容(你的库XYZ“dotnet”使用System.Reflection dnxcore5 + net45不能被UWP uap10.0应用程序使用)。这有效地结束了平台的组合噩梦。之前的目标组合dnxcore5 + net45在平台库之间创建了一个交集,每次添加都会使情况更糟。另一方面的dotnet并不限制目标上的库,而是将此限制决定转发给它的依赖项(突然出现了像着名的独角兽平台这样的新限制)。
Therefore as a library author you can target dotnet
if you just need other libraries.
因此,作为图书馆作者,如果您只需要其他库,则可以定位dotnet。
Answering your question:
回答你的问题:
- Your PCL is compatible with .Net Core style environments like DNX and UWP if you add the target
dotnet
,dnxcore50
oruap10.0
depending on the need of your library (see Owen's article for same basic compatibility with the contract Profile 259). - .Net Core is much more than a set of PCLed libraries. It is a new CLR, a new organized framework (packaged in small parts) and the infrastructure for new .Net SDKs (DNX, UWP, and whatever comes next). The term ".Net Core" targets both, the base class library "CoreFx" and the CLR "CoreCLR". But the real platforms are in reality DNX (by ASP.Net team) and UWP (by Windows team).
如果您根据库的需要添加目标dotnet,dnxcore50或uap10.0,则您的PCL与.Net Core样式环境(如DNX和UWP)兼容(有关与合同Profile 259的基本兼容性,请参阅Owen的文章)。
.Net Core不仅仅是一组PCLed库。它是一个新的CLR,一个新的有组织的框架(包装成小部件)和新的.Net SDK的基础设施(DNX,UWP,以及接下来的任何内容)。术语“.Net Core”同时针对基类库“CoreFx”和CLR“CoreCLR”。但真正的平台实际上是DNX(ASP.Net团队)和UWP(Windows团队)。
All of that answer is my current understanding of the .Net Core library situation. It is work in progress, and like mentioned in the posts, not yet public documented.
所有这些答案都是我目前对.Net核心库情况的理解。这是正在进行的工作,并且像帖子中提到的那样,尚未公开记录。
NOTE DEC 2016: Be aware, dotnet
as the predecessor to netstandard1.x
has changed in its concept starting with netstandard2.x
(.NET Core 2.0; ~JUN 2017). Beginning with netstandard2.0
there will be one common contract (the netstandard.dll) which all platforms (.NET Core, .NET Framework, Xamarin, Mono, Unity3D) implement. This contract will be extended over time and the platform have to either drop support for the latest standard, throw NotImplementedException or implement it.
注意2016年12月:请注意,作为netstandard1.x的前身,dotnet已经改变了netstandard2.x(.NET Core 2.0; ~JUN 2017)的概念。从netstandard2.0开始,将有一个共同的合同(netstandard.dll),所有平台(.NET Core,.NET Framework,Xamarin,Mono,Unity3D)都可以实现。此合同将随着时间的推移而延长,平台必须放弃对最新标准的支持,抛出NotImplementedException或实现它。
#2
0
My understanding is they both are in concept different.
我的理解是他们在概念上都不同。
- .NET Portable built upon the .NET Full, .NET Core, Windows Phone,etc, as sort of 'bridging layer'.
- It actually has no concrete implementation, consider it a 'Package' of assemblies of the 'Interfaces'(contracts).
- The scope of .NET Portable 'Package' is dynamic, depends on what 'Targets' platforms you are going to 'bridge'. It's a intersection of the platforms you target, the more platforms the smaller package.
- During runtime, this Portable layer is hooked/adapted to the real implementation of .NET full, .net core or...
.NET Portable基于.NET Full,.NET Core,Windows Phone等构建,作为“桥接层”。
它实际上没有具体的实现,认为它是'Interfaces'(契约)的程序集的'包'。
.NET Portable“Package”的范围是动态的,取决于您将要“桥接”的“目标”平台。它是您定位的平台的交叉点,较小的包平台越多。
在运行时,这个可移植层被挂钩/适应.NET full,.net核心或...的真实实现。
#1
14
There is a beautiful article series about it which solved my questions around it ...
有一篇关于它的精美文章系列解决了我的问题......
https://oren.codes/2015/06/16/demystifying-pcls-net-core-dnx-and-uwp-redux/ https://oren.codes/2015/07/29/targeting-net-core/
.Net Core has all his libraries (e.g. System.IO) in separate NuGet packages (each of them available for the SDKs DNX, UWP and .Net 4.6). Third party libraries target dnxcore50
(DNX) or uap10.0
(UWP) if they access the platform natively or rely on their features. If they do not access the platform but only rely on other packages, they should target dotnet
.
.Net Core将他的所有库(例如System.IO)放在单独的NuGet包中(每个包都可用于SDK DNX,UWP和.Net 4.6)。如果第三方库本机访问平台或依赖于其功能,则第三方库将以dnxcore50(DNX)或uap10.0(UWP)为目标。如果他们不访问平台但只依赖其他软件包,他们应该以dotnet为目标。
dotnet
effectively means: I am compatible with any platform which satisfy my dependencies (your library XYZ "dotnet" which uses System.Reflection dnxcore5+net45
could not be used by a UWP uap10.0
app). This effectively ends the combinatoric nightmare of the platforms. The previous target combination dnxcore5+net45
created an intersection between the platforms libraries and each addition would make the situation even worse. dotnet
on the other side does not restrict the library on a target but instead forwards this restriction decision to its dependencies (where suddenly new restrictions like the famous unicorn
platform can show up).
dotnet有效意味着:我与任何满足我的依赖关系的平台兼容(你的库XYZ“dotnet”使用System.Reflection dnxcore5 + net45不能被UWP uap10.0应用程序使用)。这有效地结束了平台的组合噩梦。之前的目标组合dnxcore5 + net45在平台库之间创建了一个交集,每次添加都会使情况更糟。另一方面的dotnet并不限制目标上的库,而是将此限制决定转发给它的依赖项(突然出现了像着名的独角兽平台这样的新限制)。
Therefore as a library author you can target dotnet
if you just need other libraries.
因此,作为图书馆作者,如果您只需要其他库,则可以定位dotnet。
Answering your question:
回答你的问题:
- Your PCL is compatible with .Net Core style environments like DNX and UWP if you add the target
dotnet
,dnxcore50
oruap10.0
depending on the need of your library (see Owen's article for same basic compatibility with the contract Profile 259). - .Net Core is much more than a set of PCLed libraries. It is a new CLR, a new organized framework (packaged in small parts) and the infrastructure for new .Net SDKs (DNX, UWP, and whatever comes next). The term ".Net Core" targets both, the base class library "CoreFx" and the CLR "CoreCLR". But the real platforms are in reality DNX (by ASP.Net team) and UWP (by Windows team).
如果您根据库的需要添加目标dotnet,dnxcore50或uap10.0,则您的PCL与.Net Core样式环境(如DNX和UWP)兼容(有关与合同Profile 259的基本兼容性,请参阅Owen的文章)。
.Net Core不仅仅是一组PCLed库。它是一个新的CLR,一个新的有组织的框架(包装成小部件)和新的.Net SDK的基础设施(DNX,UWP,以及接下来的任何内容)。术语“.Net Core”同时针对基类库“CoreFx”和CLR“CoreCLR”。但真正的平台实际上是DNX(ASP.Net团队)和UWP(Windows团队)。
All of that answer is my current understanding of the .Net Core library situation. It is work in progress, and like mentioned in the posts, not yet public documented.
所有这些答案都是我目前对.Net核心库情况的理解。这是正在进行的工作,并且像帖子中提到的那样,尚未公开记录。
NOTE DEC 2016: Be aware, dotnet
as the predecessor to netstandard1.x
has changed in its concept starting with netstandard2.x
(.NET Core 2.0; ~JUN 2017). Beginning with netstandard2.0
there will be one common contract (the netstandard.dll) which all platforms (.NET Core, .NET Framework, Xamarin, Mono, Unity3D) implement. This contract will be extended over time and the platform have to either drop support for the latest standard, throw NotImplementedException or implement it.
注意2016年12月:请注意,作为netstandard1.x的前身,dotnet已经改变了netstandard2.x(.NET Core 2.0; ~JUN 2017)的概念。从netstandard2.0开始,将有一个共同的合同(netstandard.dll),所有平台(.NET Core,.NET Framework,Xamarin,Mono,Unity3D)都可以实现。此合同将随着时间的推移而延长,平台必须放弃对最新标准的支持,抛出NotImplementedException或实现它。
#2
0
My understanding is they both are in concept different.
我的理解是他们在概念上都不同。
- .NET Portable built upon the .NET Full, .NET Core, Windows Phone,etc, as sort of 'bridging layer'.
- It actually has no concrete implementation, consider it a 'Package' of assemblies of the 'Interfaces'(contracts).
- The scope of .NET Portable 'Package' is dynamic, depends on what 'Targets' platforms you are going to 'bridge'. It's a intersection of the platforms you target, the more platforms the smaller package.
- During runtime, this Portable layer is hooked/adapted to the real implementation of .NET full, .net core or...
.NET Portable基于.NET Full,.NET Core,Windows Phone等构建,作为“桥接层”。
它实际上没有具体的实现,认为它是'Interfaces'(契约)的程序集的'包'。
.NET Portable“Package”的范围是动态的,取决于您将要“桥接”的“目标”平台。它是您定位的平台的交叉点,较小的包平台越多。
在运行时,这个可移植层被挂钩/适应.NET full,.net核心或...的真实实现。