Much have changed in the world of Microsoft in the last couple of years. Where before the software giant was a closed land of “we will let you know, so please wait”, it is now a case of “here is this early thing, so what do you think?”. Microsoft is all about open source, community feedback and the right tool for the job. An approach that would have seemed impossible not long ago. With this change of approach many of the traditional Microsoft products are changing too, the latest being a complete rethinking and rewriting of the .NET framework called .NET Core.
What is it?
First of all, .NET Core is a subset of the .NET Framework. This is important to remember and is the reason Microsoft recommends targeting both frameworks when building new apps. While .NET Core is feature complete, and includes the Base Class Library, many components found in the .NET Framework are not included in .NET Core.
Second, .NET Core is completely modularized. Each component is distributed via NuGet, meaning you can include only the modules necessary for your application to run and avoid the overhead of the entire .NET Framework. Each of your applications can independently live on the same machine running different versions of each of the NuGet packages. This means your apps can be updated independently and not rely on one major release of the framework.
A major focus point of .NET Core is being able to deploy it to as many types of devices as possible, regardless of size, spec level and operating system. Currently .NET Core will run on Linux, Windows and OSX, which in itself is a major achievement. It is freely available on NuGet and communities like FreeBSD is already porting the framework. When you build and deploy your app you include only the libraries you need and the target device doesn’t have to run the .NET Framework, much less a specific version of it. Your deployment package will include everything needed to run, and you will be in charge of the updates to it. This is even more cool when you realise that updates to the .NET Framework won’t break your app, and your update to incorporate any new features in the framework can be done as an app update push when you are ready. This is also a huge step towards supporting Docker containers, but that is an entirely different story.
“ NET Core is portable across various platforms, both in terms of operating systems and processor architectures. Code written for it is also portable across application stacks, such as Mono, making it feasible to move applications across app stacks as well.”
The below table outlines the major differences
|Feature||.NET Framework||.NET Core|
|Library Installation||Centralised||Distributed with each app|
|Updates||One big update. You better get your app ready.||Updates to framework are independent of app. Update NuGet packages when you are ready.|
|Platforms||Windows is the only one for me||I love everyone! Windows, OSX, Linux, you name it!|
|Base Class Library||All the things! You get the entire BCL.||All the things! You get the entire BCL.|
The .NET Core framework is a complete reengineering of the .NET Framework that we know and love(?) There are many similarities, but the major shift and change, apart from the modularity, is the split into the CoreFX libraries and the CoreCLR runtime.
CoreFX is the library implementation for .NET Core. It includes System.Collections, System.IO, System.Xml, and many other components. It is open sourced and can be found on GitHub, so you have as little or as much insight into the internals of the libraries as you want.
The runtime for .NET Core is open sourced, just like the libraries are. It includes the Just In Time compiler, RyuJIT, the .NET garbage collector and many other components.
To get started with .NET Core, just go to the official .NET Core site and follow the steps. Install the tools and in as little as 10 minutes have your first .NET Core app running.
You can use Visual Studio 2015, Visual Studio Code and the command line tools, so whatever your preference is, it is easy to get started.
One of the major usages of .NET Core is ASP.NET Core. Best said by Microsoft themselves: “As of RC2 an ASP.NET Core application is a .NET Core Console application that calls into ASP.NET specific libraries. What this means for ASP.NET Core apps is that the code that used to live in the ASP.NET Hosting libraries and automatically run your startup.cs now lives inside a Program.cs. This alignment means that a single .NET toolchain can be used for both .NET Core Console applications and ASP.NET Core applications.”
The future versions of both CoreFX and CoreCLR are publically available on GitHub as well.