Project.json 定义 dnx451 与 .dotnet ( 4.51)

Project.json 定义 dnx451 与 .dotnet ( 4.51)

问题描述:

我有一些在 asp vnext 中,我可以定义 3 种类型的运行时

I've some In asp vnext I can define 3 Types of runtime

  • dnxCore
  • dnx451
  • dotnet

在 Project.json 中,它看起来像这样:

In Project.json it looks like this:

"frameworks": 
{
    "dotnet": { },
    "dnx451": { },
    "dnxcore50": { }
}^

用户界面支持这个

我假设如下:

dnxCore 是新的 .net Core 框架.

dnxCore is the new .net Core Framework.

dotnet 是之前的运行时

dnx451:在 project.json 中定义dotnet"或dnx451"有什么不同?

dnx451: What is different when defining "dotnet" or "dnx451" in the project.json?

两者不应该与 .net 执行运行时一起运行吗?

Shouldn't both run with the .net execution runtime?

还取决于我选择的项目模板(vNext ClassLib 或 vNext Console Lib)默认包含一个或另一个.

Also depending on which project template i choose ( vNext ClassLib or vNext Console Lib) default contains one or the other.

以不同的方式回答您的问题:库应该针对 SDK 需要的环境.如果您不需要 SDK,请使用 netstandard(或在 .NET Core RC2 dotnet 之前).

Answering your question in a different way: A library should target environments which SDK its requires. If you do not require a SDK use netstandard (or before .NET Core RC2 dotnet).

  • dnxcore50 在 CoreCLR/CoreFx 上运行的 DNX SDK(已弃用,请改用 netcoreapp1.0).
  • dnx451 在 .Net 4.5.1 上运行的 DNX SDK(桌面 CLR/Full BCL 和 FCL)(已弃用,改用 net451).
  • net46 .Net Framework 4.6 SDK 在桌面 CLR/Full BCL 和 FCL 上运行.
  • uap10.0 在 .Net Native/CoreFx 上运行的 UWP Windows 10 SDK.
  • netcoreapp1.0 在 CoreCLR/CoreFx 上运行的 .NET Core 1.0 SDK.
  • netstandard1.5(RC2,dotnet 之前)声明其依赖项的任何纯 IL 代码(System.Runtime(基于)库而不是 PCL 合同).框架依赖项可用于 .Net 4.5.x 及更高版本、.NET Core 或 UWP(不同版本中基于 System.Runtime 的库集).由于 RC2 dotnet 已弃用,请改用 netstandard.
  • netstandard2.0 (.NET Core 2.0; ~JUN 2017) 任何纯粹依赖 netstandard.dll 功能集的纯 IL 代码,所有平台(.NET Core、.NET Framework、Xamarin、Mono、Unity3D)必须实现(或抛出 NotImplementedException).netstandard2.x 大致是 .NET Framework 的 BCL 库(没有 FCL 组件,如 WMI、WinForms、WPF、WCF、WWF 等).通过兼容性垫片,大多数现有的 NuGet 包将自动成为 netstandard2.0.
  • dnxcore50 DNX SDK running on CoreCLR/CoreFx (deprecated, use netcoreapp1.0 instead).
  • dnx451 DNX SDK running on .Net 4.5.1 (Desktop CLR / Full BCL and FCL) (deprecated, use net451 instead).
  • net46 .Net Framework 4.6 SDK running on Desktop CLR / Full BCL and FCL.
  • uap10.0 UWP Windows 10 SDK running on .Net Native/CoreFx.
  • netcoreapp1.0 .NET Core 1.0 SDK running on CoreCLR/CoreFx.
  • netstandard1.5 (RC2, dotnet before) any pure IL code which declares its dependencies (System.Runtime (based) libraries instead of a PCL contracts). Framework dependencies are available for .Net 4.5.x onwards, .NET Core or UWP (System.Runtime based library set in different versions). As with RC2 dotnet is deprecated, use netstandard instead.
  • netstandard2.0 (.NET Core 2.0; ~JUN 2017) any pure IL code which rely solely of the feature set of the netstandard.dll which all platforms (.NET Core, .NET Framework, Xamarin, Mono, Unity3D) have to implement (or throw NotImplementedException). The netstandard2.x is roughly the BCL library of the .NET Framework (without FCL components like WMI, WinForms, WPF, WCF, WWF, ...). By compatability shims, most existing NuGet packages will automatically be netstandard2.0.

因此,如果您的库只有一些算法或不是特定于平台的,请使用 netstandard/dotnet.如果您的任何依赖项受到限制,则此依赖项将传播到使用它的应用程序(例如 DNX、UWP、.Net46).

So if your library only has some algorithms or is not specific to the platform, use netstandard / dotnet. If any of your dependencies is restricted, this dependency will propagate up to the application (e.g. DNX, UWP, .Net46) which uses it.

我只能像玛拉基一样突出奥伦的文章系列.(他刚刚写了一个新的:https://oren.codes/2015/07/29/targeting-net-core/ 关于同一主题).

I can only highlight like Malachi the article series of Oren. (he just wrote a new one: https://oren.codes/2015/07/29/targeting-net-core/ on the same topic).

ps: dotnet/netstandard 不是一个具体的运行时,而是它的抽象.在这种情况下,它是一个目标,它甚至不指定运行时,而是说:任何正确解释 IL 的东西都可以运行.例如,dnxcore5 是指定具有特定运行时 (CoreCLR) 的 SDK(DNX) 的目标.在这种情况下,您可以对运行时行为做出进一步的假设(例如 JIT 的使用、x-plat 实现的可用性等).

ps: dotnet / netstandard is not a concrete runtime it is the abstraction of it. It is a target which in this case does not even specifiy a runtime but instead says: Anything which interprets IL correctly goes. For example dnxcore5 is a target which specify a SDK(DNX) which has a specific runtime (CoreCLR). In this case you can make further assumptions about the runtime behavior (like usage of JIT, availability of x-plat implementation, etc.).

pps:请注意,在即将发布的 RC2 版本中,dotnet 名称已转换为术语 netstandard.此外,完整的 DNX SDK 在 .NET Core 和 ASP.NET 团队之间拆分.因此,.NET Core (CoreCLR/CoreFx) 的框架名称是 netcoreapp1.0 而 99% 的 ASP.NET 堆栈只是带有 netstandard1.5 的库.DNX 绰号(dnx451dnxcore50)已被弃用.在 .NET Framework(而不是 .NET Core)上运行 ASP.NET Core 时,使用 net451.详细阅读:https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md

pps: be aware that the dotnet name was transformed into the term netstandard with the upcoming RC2 release. Also the complete DNX SDK was splitted up between the .NET Core and ASP.NET Teams. Therefore, the framework moniker for .NET Core (CoreCLR/CoreFx) is netcoreapp1.0 while 99% of the ASP.NET stack are just libraries with netstandard1.5. The DNX monikers (dnx451 and dnxcore50) where deprecated. When running ASP.NET Core on .NET Framework (instead of .NET Core) use net451. Heavy read for details: https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md

ppps:请始终注意,netstandard1.x 基于依赖契约的概念没有进一步发展,而是变成了一个(巨大的)标准契约(32k API;netstandard2.0) 必须由所有平台实现,包括即将推出的 .NET Core 2.0.这种变化的好处是可以通过使用中间兼容性垫片将大部分现有的 NuGet 包生态系统(参考 mscorlib 和朋友)集成到 netstandard2.0 包中.

ppps: Continiously be aware, that the netstandard1.x concept of dependency based contracts was not further developed but changed to one (huge) standard contract (32k APIs; netstandard2.0) which has to be implemented by all platforms including the upcoming .NET Core 2.0. This change has the advantage that most of the existing ecosystem of NuGet package (which refer mscorlib and friends) can be integrated into netstandard2.0 packages by using an intermediate compatibility shims.