.NET Core vs .NET Standard
Mar 23, 2018

.NET Core vs .NET Standard - Everything You Need To Know

SANDEEP TEETLA
SR. LEAD ARCHITECT

.Net needs no introduction and is well known among the developer community. Over the years, we have had several versions of .Net Framework. However, .Net Core and .Net Standard are new entrants to the .Net Framework family and before understanding their differences and benefits, let’s first understand the .Net Framework and see where these two new members fit in.

.Net Framework arrived 15 years ago with a single .Net stack that was used for developing Windows desktop and Windows web applications, post which other .Net implementations were introduced. Xamarin is one such implementation that is used to build mobile applications across Android, iOS and Mac OS. As the framework evolved, other versions came to the fore as part of the .Net platform.

What is .Net platform?

The platform is a group of all .Net frameworks which includes .Net Framework (old version of .Net), .Net Core, Xamarin, Windows Phone, Universal Windows Platform (UWP) and Mono. Each of these platform versions can implement a specific .Net Standard version.

What is .Net Standard?

.Net Standard in simple terms is a standard for APIs. It is the fundamental of APIs otherwise known as base class libraries that all .Net platform components (.Net Core, Xamarin, etc.) should implement to support a particular version of .Net standard.

Why the need for a Standard?

Building modern experiences requires the apps to consider several form factors and this requires multiple .Net implementations. So by targeting .Net standard, one can build various libraries which can implement .Net apps no matter on what .Net implementation or OS they run on. 

The relationship between .Net standard and .Net implementation is the same as that between HTML specification and browser, the second is the implementation of the first. All .Net implementations are required to support .Net Standard and hence it is defined as a single NuGet package.

Invariably each .Net version or platform component has an associated .Net Standard version and hence .Net Framework, .Net Core and Xamarin each implement .Net Standard for the BCL in their managed framework. Each of the afore mentioned .Net implementations have different base class libraries (BCL) and developers must master all libraries to write the code which is not easy. .Net standard solves this issue as it is the one standard library for all three .Net implementations and developers need to master just one class library.

What is .Net Core?

.Net Core is an open source, free, cross-platform implementation of .Net Framework and is available for multiple OS’s. It supports four types of applications—Cloud, Console, ASP.NET Core and Universal Windows Platform (UWP). Technically speaking, .Net Core only supports console applications while UWP and ASP.NET Core are applications that are built on top of .Net Core.

.Net Core, unlike .Net Framework, is not a Windows component and its updates come as NuGet packages. Another advantage of .Net Core is that since its runtime is installed app-local and applications are updated in package manner, these applications can be associated with the .Net Core versions and updated individually.

 

.Net Core platform

Image Source - https://andrewlock.net/understanding-net-core-netstandard-and-asp-net-core/

 

Previously, Windows store and ASP.NET Core had separate stacks but under .Net Core both share the same BCL, which is—CoreFX. The CoreFX BCL is a matching API surface for each model and is delivered through NuGet. The advantage of delivering BCL through NuGet is that it allows for choosing only required modules as opposed to having a larger list of libraries, thereby facilitating a pay-for-play model.

At the base of the .Net Core model are .NET Native Runtime and CoreCLR layers, one for each app model. These are very thin layers and do not change often and are both delivered through NuGet.

When to use .Net Core?

Since .Net Core is a cross-platform, open source framework, it can be used to develop applications on any platform. .Net Core is used –

  • When Dockers are used
  • When microservices are used in an application
  • When there is requirement of command line interface
  • When high performance and stable scale systems are needed
  • When multiple .Net versions are used side by side
  • When applications need to run on multiple platforms like Linux, Windows, macOS
    • Visual Studio code can be used on Linux, Windows and macOS
    • Visual Studio can be used on Windows with new limited version on macOS
    • Command-line can be used on all platforms

 

Targeting the right .Net standard

Different .Net versions need different implementations and instead of targeting each of them separately one can target a .Net standard version that supports the .Net platforms in question.

Overview .Net Standard vs Platforms

Image Source - https://andrewlock.net/understanding-net-core-netstandard-and-asp-net-core/

From the table above, instead of targeting WCP 10.0 and .Net Framework 4.5, we target .Net Standard 1.1, the highest platform to which both examples conform. Another advantage here is that while we target .Net Standard 1.1, we also get compatibility with other frameworks that conform to it and implement .Net Standard 1.1— in the above case, all platforms except for Windows Phone Silverlight are compatible.  

To conclude, .Net Standard is an API specification that all implementations must provide. It enables one to build libraries that can be used for any .Net implementation, and therefore brings consistency across the .Net family.

.Net Core is a framework and an implementation of .Net Standard that is optimized for building Console, Cloud, ASP.NET and UWP applications. Its SDK comes with powerful tooling that supports full command line-based development workflow in addition to Visual Studio development.

Disclaimer: The information and views set out in these blogs are those of the author(s) and do not necessarily reflect the official opinion of Microland Ltd.