.NET Core 和 .NET Framework 的 C# 库
C# library for .NET Core and .NET Framework
我正在做一个网络库 (https://github.com/Eastrall/Ether.Network) 现在针对 .NET Core 框架,但我希望同时支持 .NET Core 和 .NET Framework (4.*)
我听说要在 project.json
上添加一些行,这是一个好的解决方案吗?
有人可以帮我解决这个问题吗?谢谢
是的,修改 project.json
就是您所需要的。它应该看起来像:
{
"version": "1.0.0",
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.3": {
"imports": "dnxcore50"
}
}
}
这是将 .NET 平台标准映射到 official documentation 感兴趣的平台的方案:
一些简短的说明:
- If a library targets .NET Platform Standard version 1.3, it can only
run on .NET Framework 4.6 or later, .NET Core, Universal Windows
Platform 10 (UWP), and Mono/Xamarin platforms.
- If a library targets
.NET Platform Standard version 1.3, it can consume libraries from all
previous .NET Platform Standard versions (1.2, 1.1, 1.0).
- The
earliest .NET Framework to support a .NET Platform Standard version
is .NET Framework 4.5. This is because the new portable API surface
area (aka System.Runtime based surface area) that is used as the
foundation for the .NET Platform Standard only became available in
that version of .NET Framework. Targeting .NET Framework <= 4.0
requires multi-targeting.
有关详细信息,建议查看 official documentation。
我正在做一个网络库 (https://github.com/Eastrall/Ether.Network) 现在针对 .NET Core 框架,但我希望同时支持 .NET Core 和 .NET Framework (4.*)
我听说要在 project.json
上添加一些行,这是一个好的解决方案吗?
有人可以帮我解决这个问题吗?谢谢
是的,修改 project.json
就是您所需要的。它应该看起来像:
{
"version": "1.0.0",
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.3": {
"imports": "dnxcore50"
}
}
}
这是将 .NET 平台标准映射到 official documentation 感兴趣的平台的方案:
一些简短的说明:
- If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, .NET Core, Universal Windows Platform 10 (UWP), and Mono/Xamarin platforms.
- If a library targets .NET Platform Standard version 1.3, it can consume libraries from all previous .NET Platform Standard versions (1.2, 1.1, 1.0).
- The earliest .NET Framework to support a .NET Platform Standard version is .NET Framework 4.5. This is because the new portable API surface area (aka System.Runtime based surface area) that is used as the foundation for the .NET Platform Standard only became available in that version of .NET Framework. Targeting .NET Framework <= 4.0 requires multi-targeting.
有关详细信息,建议查看 official documentation。