简体   繁体   English

.Net Core库应该针对哪个.Net框架?

[英]Which .Net framework should my .Net Core library target?

I am enjoying the "multi-target" feature of .xproj in Visual Studio 2015 which make it really easy to target multiple .Net frameworks with the same C# project. 我喜欢Visual Studio 2015中.xproj的“多目标”功能,这使使用同一C#项目定位多个.Net框架变得非常容易。 I am currently targeting .Net 4.5.2, 4.6, 4.6.1, 4.6.2, .Net Standard 1.3 and .Net Standard 1.6 and I am packaging all the DLLs in a nuget package. 我目前的目标是.Net 4.5.2、4.6、4.6.1、4.6.2,.Net Standard 1.3和.Net Standard 1.6,并且我将所有DLL打包在nuget包中。

Do you think this is overkill? 您认为这太过分了吗? Should I target fewer frameworks? 我应该针对较少的框架吗? More? 更多?

By the way, I know xproj is eventually going away in favor of .csproj, but that's what I'm using for the time being. 顺便说一句,我知道xproj最终将取代.csproj,但这就是我暂时使用的。

If you don't have any conditional compilation yet, then you should leave only .NET Framework 4.5.2 and .NET Standard 1.3. 如果还没有条件编译,则应仅保留.NET Framework 4.5.2和.NET Standard 1.3。

The reason is simple. 原因很简单。 If the package works for .NET Framework 4.5.2, it works for all .NET Framework with a bigger version. 如果该软件包适用于.NET Framework 4.5.2,则适用于所有具有较大版本的.NET Framework。 No need to target them separately. 无需将它们分别定位。

The same applies to .NET Standard. .NET标准也是如此。 If the package targets .NET Standard 1.3, then it can work fine for .NET Standard 1.4/1.5/1.6/2.0. 如果该软件包以.NET Standard 1.3为目标,则可以在.NET Standard 1.4 / 1.5 / 1.6 / 2.0下正常运行。

You do have to target both because .NET Framework 4.5.2 does not implement .NET Standard 1.3. 您必须同时针对这两个目标,因为.NET Framework 4.5.2没有实现.NET Standard 1.3。 Probably you don't want to target .NET Standard 1.2, as it is too limited. 可能您不想以.NET Standard 1.2为目标,因为它太有限了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM