How to install Dotnet 6 on ubuntu 20.04

In this tutorial, we are going to learn how to install dotnet 6 on Ubuntu 20.04. Also in this tutorial, I will tell you about the new features of dotnet 6, what is dotnet 6. Let’s jump right in.

Dotnet is a free cross-platform and open-source developer platform for building web, mobile, microservices, cloud, and many other applications. You can write your dotnet applications with C#, F#, and visual basic.

What dotnet 6 can do

Dotnet 6 improve on the features introduced during the dotnet 5 phase.

  • Simplified development by reducuing the codebase on C# making it easy to read and analyze any code written in C#, F#.
  • Improved performance by lowering compute costs on the cloud.
  • improved productivity with the introduction of new git tooling, intelligent code editing, provision of robust diagnostics and testing tools.

New fatures in dotnet 6

Notable features introduced include the following:

  • System.io.filestream have been rewritten to provide better performance and reliability on windows platforms
  • Introduction of profile-guided optimization where the JIT compiler generates optimized codes
  • Introduction of crossgen2 which provide head of time compilation (AOT) to improve the startup time of the app.
  • Introduction of Arm64 support
  • Introduction of hot reload that is a feature that lets you modify your apps’ source code and instantly apply those changes to your running application.
  • It adds a new source generator for system.text.json
  • Introduction of a new document object model (DOM) which supplement pre-existing readonly dom

Read about many other new features in detail here.

Prerequisites

Before installing dotnet make sure you have the following:

  • Ubuntu 20.04
  • Sudo or root privileges
  • Basic command line terminal experience

Install dotnet 6 on Ubuntu 20.04

1. Run system updates

Before running any installation in any Linux distribution make sure you run a system update in order to make the system repositories up to date. Use the following command

# update
$ sudo apt update
# upgrade
$ sudo apt upgrade -y

2. Add Microsoft package signing key

Download Microsoft key and install it into the list of trusted keys with the following command.

$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

You will get an output like this

output
--2022-01-17 10:43:37--  https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Resolving packages.microsoft.com (packages.microsoft.com)... 13.81.215.193
Connecting to packages.microsoft.com (packages.microsoft.com)|13.81.215.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3124 (3.1K) [application/octet-stream]
Saving to: ‘packages-microsoft-prod.deb’

packages-microsoft-prod.deb  100%[===========================================>]   3.05K  --.-KB/s    in 0s      

2022-01-17 10:43:37 (327 MB/s) - ‘packages-microsoft-prod.deb’ saved [3124/3124]

After the download is complete, then you need to install with the following command;

$ sudo dpkg -i packages-microsoft-prod.deb

The output will look like this

Output
Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 94650 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-ubuntu20.04.1) ...
Setting up packages-microsoft-prod (1.0-ubuntu20.04.1) ...

Before you can install SDK make sure to update your system again

$ sudo apt update
Hit:2 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease                    
Hit:3 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease                                            
Hit:4 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease                                          
Get:5 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease [10.5 kB]                      
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease                
Get:7 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 Packages [122 kB]

3. Install dotnet 6 SDK

SDK allows you to develop apps with the .Net platform, so it’s required that be installed before running the installation of .Net 6. So to install SDK run the following command on your terminal.

$ sudo apt install -y dotnet-sdk-6.0

This will be the sample output

Output
Welcome to .NET!
---------------------
Learn more about .NET: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Processing triggers for man-db (2.9.1-1) ...

4. Install dotnet 6 runtime

We are going to install ASP.core runtime. Runtime allows you to run apps that were developed using the .NET framework.

Alternatively, you can install dotnet-runtime. We do this to make all the apps developed using .NET frameworks become compatible because this is always a pain when it comes to Microsoft products.

Install ASP.Core runtime environment

$ sudo apt install -y aspnetcore-runtime-6.0

I can see that there is no need to install this because SDK install with it in the process. Check out this output

Output
Reading package lists... Done
Building dependency tree       
Reading state information... Done
aspnetcore-runtime-6.0 is already the newest version (6.0.1-1).
aspnetcore-runtime-6.0 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Install dotnet runtime environment

To install dotnet-runtime run the following command on your terminal.

$ sudo apt install -y dotnet-runtime-6.0

Lets check the version of dotnet installed with this command.

$ dotnet --version
6.0.101

Conclusion

Congratulations, you have successfully installed the dotnet framework on Ubuntu 20.04. Go ahead and begin your coding challenges.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published. Required fields are marked *