In this .Net Core tutorial, you will learn the difference .NET Core vs .NET Framework, and DotNet CLI.

.NET Core History

Let’s get started with the history of the .Net Platform introduced by Microsoft Corporation.

.NET Core vs .NET Framework

.NET Framework

A development platform for building web applications, services, and mobile applications.

It contains a common language runtime (CLR) and, the .NET Framework class library that support an extensive range of technologies.

Runs on Windows OS only.

The most recent official release of .NET is 4.7.2

.NET Core Framework

Modular and smaller implementation of .NET.

Cross-platform and Open Source. So we can run it on Windows, Linux, and Mac operating systems.

It supports containers such as Dockers, Kubernetes, etc.

It supports Microservices Architecture.

Optimized for high performance and scalability.

It supports Cross-platform development tools – VS Code, Dot Net CLI.

It built for the next 10 years of software development.

In a couple of years, .NET Core will replace all the implementation of .NET.

What .NET Core does not support?

WPF

Winforms

WebForms

ASMX Services

WCF Services

WWF

LINQ to SQL

So, these are the things actually we can not develop on top of .Net Core but It doesn’t mean that I can not consume the WCF like ASMX services in a .Net Core application. We can consume but can not develop. And Microsoft team is constantly working on WCF support as well so soon you will get the support of WCF on top of .Net Core.

.NET Core CLI Compilation

Roslyn – .NET Core Compiler

A new .NET Compiler Platform which is based on compiler “As-a-Service”.

An open-source C# and Visual Basic compiler with rich code analysis APIs.

It enables building code analysis tools with the same APIs that are used by Visual Studio.

CoreCLR

Runtime implementation of .NET Core.

A group of technologies that are fundamental to the runtime, such as RyuJIT, Garbage Collector, native interop, and many other components.

The CoreCLR is cross-platform and CLR is not.

RyuJIT (Just-In-Time compiler)

Next-generation Just-In-Time (JIT) compiler for .NET Core.

Supports High-performance JIT architecture, focused on high throughput, JIT compilation.

The new JIT is twice as fast, meaning apps compiled with RyuJIT start-up to 30 percent faster.

Dotnet Core CLI Commands

dotnet new : (Scaffolds a minimal app) To create a .net core based application.

dotnet restore : (Restore packages for the project)

dotnet run : (Compiles and run the app)

dotnet build : (Compiles to IL)

dotnet build -native : (Compiles a single executable)

dotnet dosomethingcool : (Build your own command)

DotNet CLI Application Templates

Enter command dotnet new -l

So let me show the way how these .NET CLI is working here. But first of all, you should know how to prepare your system. Make sure everyone has downloaded the visual studio on your machine just sharing the link from where you can download the visual studio from the official web site https://visualstudio.microsoft.com/. From there you can download the VS 2017/19 community edition (free).

In the same way, you can download Node.js from the https://nodejs.org/en/ link and SQL Server 2017/19 express edition as well. As an IDE you can download Visual Studio Code and download the .NET Core SDK.

Verify the Environment

The environment you can verify using the command prompt and entering the command dotnet-v, dotnet –version

Here also you can check all the available templates using the command dotnet new -l.

So you can see the available templates here which you can use for creating your .net core based application such as console application, class library, etc using .net core CLI.

Dotnet Core Command-Line Application

Now let me show the way how you can create and run a .NET Core application using CLI Tools.

Step1: Enter a command dotnet new console, It will create the console application as shown below;

Step2: After successfully created the project, open the project in the Visual Studio Code as shown below. Also, you can open the same project in Visual Studio as well.

.NET Standard Library

We have the three extensions of the .NET as we have .Net Framework, .NET Core, and Xamarin. But now the requirement is how we can share the code across these three implementations. For code sharing, we have here the .NET Standard Library. So using this library we can share the code among all these three implementations of .NET.

So just create a .Net Standard Library and you can use it with the Xamarin, .Net Core, and the .Net Framework project. Let me share the way how we can share the code here by following the below steps:-

Step1: Open the Visual Studio 2017/19 and create a new project with a blank solution named CodeSharing as shown below:-

Step2: Now create a new MVC 5 project under this solution by selecting a .NET framework 4.6.1.

Step3: Now create the ASP.Net Core web application (Model View Controller) project by selecting ASP.NET Core 2.1 named WebAppCore.

Step4: Next you need to create a new Class Library (.Net Standard) named DomainModel.

Step5: Now create a User class and add properties like UserId, Name, etc.

Step6: Then add a reference to the MVC5 project and WebAppCore project. Build the solution.

So it is the style that we can use for code sharing between the different versions or you can say different implementation of the .NET based application. The same .Net Standard library we can access in Xamarin as well.

Download Source Code

Conclusion

I hope you liked this article on the dotnet CLI. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.