微軟為了統一微軟平台,造就了.netStandard,不管之前的Framework還是最新的.netCore都必須支持.netStandard標准來統一各個平台的開發api。
以下是之前的微軟各個平台構成,這種分叉對於開發人員為多個.NET平台編寫代碼構成了巨大的問題,因為沒有一個統一的類庫來定位:

目前有三種主要的.NET平台,這意味着您必須掌握三種不同的基類庫,以便編寫可在其中運行的所有代碼。由於行業現在比起.NET最初創建的時候更加多樣化,如果我們定義一個標准,那將極大簡化開發過程並且規范各個平台開發的一致性。
以下是.netStandard之后的微軟平台構成:

從圖可看出三大平台的底層都是.netStandard來支撐,對於開發人員來說,這意味着他們只需要掌握一個基類庫。面向.NET Standard的庫將能夠在所有.NET平台上運行。平台提供商不必猜測他們需要提供哪些API才能使用NuGet上可用的庫。
我們需要.NET標准有兩個原因:
1.Driving force for consistency .We want to have an agreed upon set of required APIs that all .NET platforms have to implement in order to gain access to the .NET library ecosystem.
2.Foundation for great cross-platform tooling .We want a simplified tooling experience that allows you to target the commonality of all .NET platforms by choosing a single version number.
.NET Standard 2.0有什么新功能?
當
NET Core 1.0時,微軟還引入了.NET Standard。有多個版本的.NET標准,以表示所有當前平台的API可用性。下表顯示了現有平台的哪個版本與給定版本的.NET Standard兼容情況:

箭頭表示該平台支持更高版本的.NET Standard。例如,.NET Core 1.0支持.NET Standard 1.6版,這就是為什么有較低版本1.0 - 1.5的箭頭指向的原因。
從圖可知微軟在.NET Framework4.5開始執行.NET Standard1.1標准(換句話說也許是.NET Standard1.1以.NET Framework為標准制定,畢竟.NET Framework4.5的時候還沒有出現.NET Standard標准),這樣的話那以后就可以開發1.1版本的.NET Standard作為中間間供.NET Framework引用,也可以供支持了1.1標准的其他平台的引用(例如.NET Core或者未來微軟開發的新的平台,只要支持.NET Standard1.1的即可)。這樣極大的統一了微軟各個平台代碼的共享。
官方介紹
You can use this table to understand what the highest version of .NET Standard is that you can target, based on which .NET platforms you intend to run on.For instance, if you want to run on .NET Framework 4.5 and .NET Core 1.0, you can at most target .NET Standard 1.1.(您可以使用此表來決定您要運行的.NET平台來可以定位的最高版本的.NET Standard。(官方這段話大意是如果開發例如.NET Framework4.5 和 .NET Core 1.0上運行的程序,那最多只能開發.NET Standard1.1版本的程序集)
From a library targeting .NET Standard you’ll be able to reference two kinds of other libraries:
- .NET Standard, if their version is lower or equal to the version you’re targeting.
- Portable Class Libraries, if their profile can be mapped to a .NET Standard version and that version is lower or equal to the version you’re targeting.
(以上大意是如果你開發了.NET Standard程序集,那你可以引用兩種兩種類型的類庫:
1.引用不大於當前.NET Standard 版本的.NET Standard
2.引用PCL,前提是其描述文件對應到不大於您當前 .NET Standard版本)
The following improvements are included in .NET Core 2.0 Preview 1:
- Massive API increase (>100%) relative to .NET Core 1.x.
- Support for .NET Standard 2.0.
- Support for referencing .NET Framework libraries and NuGet packages.
- Support for Visual Basic.
以上大意是:
.NET Core 2.0 Preview預覽版包括四點改進:
- 相對於Core1.1增加大量api
- 支持.NET Standard2.0
- 支持引用.NET Framework和NuGet的包
- 支持VB語言
.NET Standard 2.0
.NET Standard allows sharing code, binaries and skills across all flavors of .NET, including .NET Framework, .NET Core, Xamarin, Unity, and UWP(以上大意是開發的.net Standard2.0類庫可以在微軟旗下任意平台引用,例如在Framework和Xamarin和Unity或者UWP項目下都可以引用同一個.NET Standard類庫)
Here is what’s new with .NET Standard 2.0:
- Has a much bigger API surface. It’s extended to cover the intersection between
.NET Framework and Xamarin. This also makes .NET Core 2.0 much bigger as it
implements .NET Standard 2.0. The total number of APIs added to .NET Standard
is ~20,000.
- Can reference existing .NET Framework libraries. The best thing is:
no recompile required, so this includes existing NuGet packages. Of course,
this will only work if the consumed libraries use APIs that exist in .NET
Standard. However, our extensive API surface results in 70% of all NuGet
packages to be API compatible with .NET Standard 2.0.
(以上大意是 .NET Standard 2.0兩個新功能:
- 支持更多的api
- 可以引用現有.NET Framework,前提是.NET Framework使用了在.NET Standard 存在的Api才有效)
Visual Studio 2017 Improvements
Visual Studio 2017 continues to use .NET Core 1.x by default.You need to install the .NET Core SDK 2.0 Preview 1 to get .NET Core 2.0 support.(以上大意是VS17默認情況下繼續使用Core1.X 的版本,除非你安裝2.0預覽版得到2.0支持。.NET Core2.0預覽版下載地址
https://www.microsoft.com/net/core/preview#windowscmd)