Trying .NET 5 Preview in Linux

Introduction 

 
.NET 5 is the next big thing offered by Microsoft. It will be a unified version of the .NET Framework and .NET Core. An important Milestone to reduce the complex Versioning of .NET. Going forward it will be an evolution of .NET Core. It will be shipped in November 2020. You can read more about it from here. In this tutorial, we can use any .NET 5 Preview available from Microsoft at this time. All the packages installation works the same way. Microsoft's Plans for .NET to work on cross-platform and Open Source World is an important step to increase the developer's reach. 
 
In this, we are going to try Linux Flavour of .NET 5. We must know how to use this in Linux. The Technology Stack in Linux requires VS Code as an IDE. We can install Omnisharp Plugin as well in VS Code for Scaffolding Templates. In Terminal Dotnet, CLI can also work. Let's configure this in Linux. In this tutorial, we are going to use VS Code and Dotnet CLI. Let us begin!!
 
Download .NET Core and Runtime from Official Microsoft’s Website.
 
Now open the directory in which .tar.gz files have been downloaded. Open Terminal and run the following commands:
  1. Setup .NET 5 SDK,

    mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-5.0.100-preview.3.20216.6-linux-x64.tar.gz -C $HOME/dotnet

    Note
    Instead of dotnet-sdk-5.0.100-preview.3.20216.6-linux-x64.tar.gz it can be any current version available at this time.
  1. Then Setup .NET 5 Runtime:

    mkdir -p $HOME/dotnet && tar zxf aspnetcore-runtime-5.0.0-preview.3.20215.14-linux-x64.tar.gz -C $HOME/dotnet

    Note
    Instead of aspnetcore-runtime-5.0.0-preview.3.20215.14-linux-x64.tar.gz it can be any current version available at this time.
  1. Run the commands below to make “dotnet” available in Terminal for Current Session.

    export DOTNET_ROOT=$HOME/dotnet
    export PATH=$PATH:$HOME/dotnet
  1. Now check the available SDKs

    dotnet --list-sdks

    We need only 5.0.100-preview.3.20216.6 or something like this to make sure that it is available.
  1. Create an App In VS Code. Open VS Code and Repeat Step 3, then run the following commands in the Terminal:

    mkdir WebApp5
    cd WebApp5 
    dotnet new sln
    dotnet new mvc -o "WebApp5.App" -f "netcoreapp5"
    dotnet sln add WebApp5.App/WebApp5.App.csproj
    cd WebApp5.App
As of Now, Existing Target Framework set is in WebApp5.App.csproj is,
  1. <PropertyGroup>  
  2.    <TargetFramework>netcoreapp5.0</TargetFramework>  
  3.  </PropertyGroup>   
Since beyond Preview 3 TFM it will be net5.0, Microsoft supports both in Preview 3 and does not throw an error. After Preview 3, things will change much more. TFM in *.csproj file will have net5.0 and there will be a lot of others that we will explore in the coming days.
 
[Source: https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-preview-3/]
 
Therefore, if we are using Preview 3, then set the Target Framework to net5.0.
  1. <PropertyGroup>  
  2.    <TargetFramework>net5.0</TargetFramework>  
  3. </PropertyGroup>   
At this stage, net5.0 will be the TFM for future releases. Right now, net5.0 must be set to execute the app as per the Release Notes. Now, let’s run the app.
 
dotnet run
 
 
That’s it! We are done. Kindly share your feedback and comments. Let's learn more together by sharing knowledge.