The goal of .NET Standard is “one library to rule them all”, or more simply, one set of APIs that can be used across platforms without compatibility issues.
At the moment, developers targeting one of the .NET variants need to understand the underlying platform to be able to develop for it. What makes it even more complicated is that there are multiple platform and API versions. Currently, the best solution is to create a PCL (Portable Class Library) and use ‘Bait & Switch’ to switch out a set of interfaces (so called facades) with the actual native implementation. This works well for abstracting platform specific features, but for more common API’s such as XML, Networking, IO, or even Primitives or Collections, you just want these to be available through a standardized framework.
“.NET Standard solves the code sharing problem for .NET developers across all platforms by bringing together the APIs that you expect and love across environments: desktop applications, mobile apps & games, and cloud services,” writes Microsoft’s Immo Landwerth, in a blog post.
This doesn’t mean that all compatibility issues are gone, but it does give a consistency in APIs. This also means that the smallest API surface, which is .NET Core will be updated to work with all the other platforms, and even behave the same. For developers, this means they only have to create and maintain one base class library.
For .NET Standard 2.0 the major decision was made to revert to compatibility with .NET Standard 1.4, drop the extra API’s added in 1.5 and 1.6, and make sure that all the API’s in 1.4 work on all platforms! As a little bonus it will be built on .NET 4.6.1.
What impact does this have on open source projects and library creators? In general they should really consider switching to .NET Standard because it will replace Portable Class Libraries for targeting multiple .NET platforms. In order to make an informed decision, consider the following:
→ Use the NET Portability Analyzer to see how compatible your code base is with the various versions of .NET Standard.
→ Look at the .NET Standard documentation to ensure you can reach the platforms that are important to you.
Moving forward the .NET team recommends that you use .NET Standard instead of Portable Class Libraries. The tooling for targeting .NET Standard 2.0 will ship with the upcoming release of Visual Studio, code-named “Dev 15”. You’ll reference .NET Standard as a NuGet package. It will have first class support from Visual Studio, VS Code as well as Xamarin Studio.
You can follow the progress of .NET Standard on the GitHub repository.