What is the difference between .NET Core and .NET Standard Class Library project types?
net core vs net standard performance
reference net standard library from net core
net core 3 net standard
difference between net core and net framework
reference net standard library from net framework
difference between asp net core and net core
difference between .net framework and .net platform
In Visual Studio, there are at least 3 different types of class library you can create:
- Class Library (.NET Framework)
- Class Library (.NET Standard)
- Class Library (.NET Core)
While the first is what we've been using for years, a major point of confusion I've been having is when to use the .NET Standard and .NET Core class library types. I've been bitten by this recently when attempting to multi-target different framework versions, and creating a unit test project.
So, what is the difference between Class Library (.NET Standard) and Class Library (.NET Core), why do both exist, and when should we use one over the other?
When should we use one over the other?
The decision is a trade-off between compatibility and API access.
Use a .NET Standard library when you want to increase the number of apps that will be compatible with your library, and you are okay with a decrease in the .NET API surface area your library can access.
Use a .NET Core library when you want to increase the .NET API surface area your library can access, and you are okay with allowing only .NET Core apps to be compatible with your library.
For example, a library that targets .NET Standard 1.3 will be compatible with apps that target .NET Framework 4.6, .NET Core 1.0, Universal Windows Platform 10.0, and any other platform that supports .NET Standard 1.3. The library will not have access to some parts of the .NET API, though. For instance, the
Microsoft.NETCore.CoreCLR package is compatible with .NET Core but not with .NET Standard.
What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)?
The Package-based frameworks section describes the difference.
Compatibility: Libraries that target .NET Standard will run on any .NET Standard compliant runtime, such as .NET Core, .NET Framework, Mono/Xamarin. On the other hand, libraries that target .NET Core can only run on the .NET Core runtime.
API Surface Area: .NET Standard libraries come with everything in
NETStandard.Library whereas .NET Core libraries come with everything in
Microsoft.NETCore.App. The latter includes approximately 20 additional libraries, some of which we can add manually to our .NET Standard library (such as
System.Threading.Thread) and some of which are not compatible with the .NET Standard (such as
Also, .NET Core libraries specify a runtime and come with an application model. That's important, for instance, to make unit test class libraries runnable.
Why do both exist?
Ignoring libraries for a moment, the reason that .NET Standard exists is for portability; it defines a set of APIs that .NET platforms agree to implement. Any platform that implements a .NET Standard is compatible with libraries that target that .NET Standard. One of those compatible platforms is .NET Core.
Coming back to libraries, the .NET Standard library templates exist to run on multiple runtimes (at the expense of API surface area). Obversely, the .NET Core library templates exist to access more API surface area (at the expense of compatibility) and to specify a platform against which to build an executable.
What is the difference between .NET Core and .NET Standard Class , You might have already noticed different project templates in Visual To that end this article briefly explains each of these three types of class libararies. NET Standard class library in the New Project dialog of Visual Studio If we carefully read the description which is written under Class Library (.NET Standard) and Class Library (.NET Core), it says that target platforms are .NET Standard and .NET Core respectively. This might give us a feeling that the .NET Standard is another framework or implementation of .NET:
A .Net Core Class Library is built upon the .Net Standard. If you want to implement a library that is portable to the .Net Framework, .Net Core and Xamarin, choose a .Net Standard Library
.Net Core will ultimately implement .Net Standard 2 (as will Xamarin and .Net Framework)
.Net Core, Xamarin and .Net Framework can, therefore, be identified as flavours of .Net Standard
To future-proof your applications for code sharing and reuse , you would rather implement .Net Standard libraries.
Microsoft also recommends that you use .NET Standard instead of Portable Class Libraries.
To quote MSDN as an authoritative source, .Net Standard is intended to be One Library to Rule Them All. As pictures are worth a thousand words, the following will make things very clear:
1. Your current application scenario (fragmented)
Like most of us, you are probably in the situation below: (.Net Framework, Xamarin and now .Net Core flavoured applications)
2. What the .Net Standard Library will enable for you (cross-framework compatibility)
Implementing a .Net Standard Library allows code sharing across all these different flavours:
For the impatient:
- .NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:
- .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation.
- .NET Standard 2.0 will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
- .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
- .NET Standard will replace Portable Class Libraries (PCLs) as the tooling story for building multi-platform .NET libraries.
For a table to help understand what the highest version of .NET Standard that you can target, based on which .NET platforms you intend to run on, head over here.
Sources: MSDN: Introducing .Net Standard
Class library projects : .NET Framework, .NET Core, and .NET , .NET Standard: This is the set of fundamental APIs (commonly referred to as base Type “dotnet new” to see the different templates that come pre-installed. To do this, first create a class library project that's parallel to your hello project: C# Class Library (.NET Framework) Class Library (.NET Standard) Class Library (.NET Core) While the first is what we've been using for years, a major point of confusion I've been having is when to use the .NET Standard and .NET Core class library types.
So the short answer would be:
IAnimal == .NetStandard (General) ICat == .NetCore (Less General) IDog == .NetFramework (Specific / oldest and has the most features)
Demystifying .NET Core and .NET Standard, Furthermore, let's create three projects for each platform: StandarLib is a Class Library project type that targets the .NET Standard .NET Core is a free, cross-platform, open source implementation of the managed framework. It supports four types of applications: console, ASP.NET Core, cloud, and Universal Windows Platform (UWP). Windows Forms and Windows Presentation Foundation(WPF) are not part of .NET Core.
.Net Framework and .Net Core are two different implementations of the .Net runtime. Both Core and Framework (but especially Framework) have different profiles that include larger or smaller (or just plain different) selections of the many APIs and assemblies Microsoft has created for .Net, depending on where they are installed and in what profile. For example, there are some different APIs available in Universal Windows apps than in the "normal" Windows profile. Even on Windows, you might have the "Client" profile vs the "Full" profile. Additionally, there are other implementations (like Mono) that have their own sets of libraries.
.Net Standard is a specification for which sets of API libraries and assemblies must be available. An app written for .Net Standard 1.0 should be able to compile and run with any version of Framework, Core, Mono, etc, that advertises support for the .Net Standard 1.0 collection of libraries. Similar is true for .Net Standard 1.1, 1.5, 1.6, 2.0, etc. As long as the runtime provides support for the version of Standard targeted by your program, your program should run there.
A project targeted at a version of Standard will not be able to make use of features that are not included in that revision of the standard. This doesn't mean you can't take dependencies on other assemblies, or APIs published by other vendors (ie: items on NuGet). But it does mean that any dependencies you take must also include support for your version of .Net Standard. .Net Standard is evolving quickly, but it's still new enough, and cares enough about some of the smaller runtime profiles, that this limitation can feel stifling. (Note a year and a half later: this is starting to change, and recent .Net Standard versions are much nicer and more full-featured).
On the other hand, an app targeted at Standard should be able to be used in more deployment situations, since in theory it can run with Core, Framework, Mono, etc. For a class library project looking for wide distribution, that's an attractive promise. For a class library project used mainly for internal purposes, it may not be as much of a concern.
.Net Standard can also be useful in situations where the SysAdmin team is wanting to move from ASP.Net on Windows to ASP.Net for .Net Core on Linux for philosophical or cost reasons, but the Development team wants to continue working against .Net Framework in Visual Studio on Windows.
Differences Between .NET Framework, .NET Core, and .NET Standard, In Visual Studio, there are at least 3 different types of class library you can create: NET Standard library when you want to increase the number of apps -difference-between-net-core-and-net-standard-class-library-project. API Surface Area: .NET Standard libraries come with everything in NETStandard.Library whereas .NET Core libraries come with everything in Microsoft.NETCore.App. The latter includes approximately 20 additional libraries, some of which we can add manually to our .NET Standard library (such as System.Threading.Thread ) and some of which are not compatible with the .NET Standard (such as Microsoft.NETCore.CoreCLR ).
.NET Framework and .NET Core are both frameworks.
.NET Standard is standard (in other words, specification).
You can make executable project (like Console application, or ASP.NET application) with .NET Framework and .NET Core, but not with .NET Standard.
With .NET Standard you can make only class-library project that cannot be executed standalone and should be referenced by another .NET Core or .NET Framework executable project.
.NET Standard vs. .NET Core, Net platforms should implement to unify the Base Class Libraries of different . Studio 2012, we have a project type called Portable Class Library project for this. Build a .NET Standard library with C# and the .NET Core SDK in Visual Studio 2017. A class library defines types and methods that are called by an application. A class library that targets the .NET Standard 2.0 allows your library to be called by any .NET implementation that supports that version of the .NET Standard.
What is .Net Standard? How it is different from .Net Core and , Share this What is the difference between .NET Core and .NET Standard Class Library project types? Blog and explore more. Learn what the difference between .NET Core and .NET Framework is and when to choose .NET Core. .NET Core is the new open-source and cross-platform framework to build applications for all operating system including Windows, Mac, and Linux.
.Net Framework vs .Net Core vs .Net Standard, Today, we will understand the difference between and . Net Core or Xamarin application, you required Base Class Library (BCL) that is used for sharing the The latest version of .NET Standard specification is 2.1. The .NET Framework 4.7 and .NET Core 2.1 implement .NET Standard 2.0. The .NET Framework 4.8 will continue to implement .NET Standard 2.0 and .NET Core 3.0 (and also Mono and Xamarin) will implement .NET Standard 2.1.
.NET Standard Explained: How To Share Code, NET Standard versioning, class libraries, and portable class libraries. NET Core and Mono for Xamarin), class libraries, and a common infrastructure (runtime When you want to share code between different runtimes in the . Shared Projects are a project template in Visual Studio that do not result in .Net Standard is a specification which dictates what the Base Class Libraries of different .Net platforms should implement to unify the Base Class Libraries of different .Net Platforms. Here, Platform means full .NetFramework, .Net Core, Xamarin, Silverlight, XBox etc.
- You missed one: Class Library (Portable). Core == framework, .NET Standard == portable.
- There was one from Xamarin too, but these other ones don't add any value to the question :)
- Well, they do. The core idea is the they gave up on the portable approach, it suffered too heavily from the n! problem with way too many profiles. So now you've got 7 standards to choose from. Most are not actually portable right now :) .NETCore is not done by a long shot, probably takes another two years at the clip they are going.
- OP said "at least 3 different types". The post was accurate.
- I was confused by the naming of Core which is not a core subset of neither the Standard nor the Framework plateform. Also we regularly see ASP associated with .Net Core. This is also very confusing...
- Very good answer. An additional question though (relates to this question: why is an application model necessary to run unit tests? This was never the case in the past, when we used non-runnable class libraries to hold collections of unit tests.
- I've updated my answer to the linked question. TL;DR; In the past, class libraries targeted the full framework, which includes an application model.
- You forgot to cover Class Library (.NET Framework), is it compatible with .NET Standard and .NET Core?
- This diagram really helped me get it.
- @BerBar The original question was about the difference between .NET Standard and .NET Core. That's why I omitted cross-platform details, because cross-platform is not a difference between Core and Standard. I've intentionally kept my answer scoped to the original question.
- ASP.NET Core is a little misplaced in that graphic, as it can be used with the full .NET Framework, not only .NET Core, because it actually targets .NET Standard.