3
votes

In the new project wizard in Visual Studio 2017, I see both the option to create a new .NET Standard library as well as a new .NET Core library. I understand that .NET Standard is a specification while .NET Core is a cross-platform implementation of that spec.

But can someone explain the real differences when creating libraries from each of the following ways? To make matters worse, if you look closely, both dialogs also have a drop-down on the top that says ".NET Framework 4.6.2" :( - what's up with that?

.NET Standard Library

Standard

.NET Core Library

Core

Side note: The naming convention is confusing. ".NET 5" sounds simpler

2
The naming convention is because starting with 4 they started to use Semantic Versioning, They won't change to .NET 5 till they make a change to the framework that would cause it to be not backward compatible with stuff developed with 4.x. That is the point of the numbering system, if you are running on a version of 4.x that is greater or equal to the version you wrote your code for you know your code will compile without any changes required at all. If you try to compile your code on 5.x you know you need to check for compatability.Scott Chamberlain
But they discarded that thought when calling it .net core 2.0 :( blogs.msdn.microsoft.com/dotnet/2016/09/26/…DeepSpace101
We are talking about the .NET framework not the .net core versioning.Scott Chamberlain
Remember the PCL library project templates? The previous solution to creating cross-platform libraries. That's retired for .NETCore, suffering too much from the n! problem, replaced by .NETStandard. The compatibility grid is here. Do keep in mind that this is work in progress, 2.0 will take a while to show up.Hans Passant

2 Answers

3
votes

The upper drop down (".NET Framework 4.6.2") do nothing when you want to create .NET Core or .NET Standard project.

(Maybe related conversation: https://twitter.com/bradwilson/status/836434975985577984)

3
votes

Using this diagram

enter image description here

If you create a .NET Core library your library can only be used by things in the Blue section and only use things from the Blue section or the Red section. If you create a .NET Standard library your library can be used by things in the Green, Blue, Orange, and Red sections but only use things from the Red section.

The reason you may want to use a Core Library over a standard library is you have potentially access to more functions and libraries to call from your code if you know you are targeting Core only. You don't need to keep the public API's surface area you consume restricted to things that are allowable in all 4 sections.