This brief tutorial shows students and new users how to install Microsoft .NET on Ubuntu 20.04 | 18.04 LTS.
Developers looking to develop .NET applications on Ubuntu, the first thing to do is to install .NET framework. Initially, the .NET framework only supported Windows systems. Other systems and operating systems were excluded.
With the latest .NET 5 release, it was developed as cross-platform and open-source framework. It now supports Linux and MacOS systems out of the box. It is also modular and lightweight
The best way to use .NET on Ubuntu is to install the Software Development Kit (SDK), which also includes the .NET Runtime by default. This will allow you to develop and run .NET applications.
To get started with installing .NET SDK on Ubuntu, follow the steps below:
Install required packages
Before installing .NET SDK, you will want to install some basic packages. This package allows you to install the .NET SDK securely via HTTPS
To do that, make sure to install the apt-transport-https package using the command below.
sudo apt update sudo apt install apt-transport-https
Add .NET Repository
Now that the package is installed above, run the command below to add Microsoft’s package repository to your system.
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb
Install .NET 5 SDK
After that, you should be able to install .NET simply by running the commands below.
sudo apt update sudo apt install dotnet-sdk-5.0
After installing, you should get a success message similar to the one below:
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) …
After installing, you can verify that .NET is installed by running the commands below.
The command above will display the version of .NET installed.
Output: 5.0.202 [/usr/share/dotnet/sdk]
Also verify that .NET runtime is functioning.
That should display similar lines as shown below:
Output: Microsoft.AspNetCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Install .NET via Snap
Alternatively, one can install .NET via Snap package management. Some people will prefer installing .NET via Snap as it might be the quickest and easiest.
Snaps are containerized software packages that are simple to create and install.
Snap applications are packaged with all their dependencies to run on all popular Linux distributions from a single build which allow them to update automatically and roll back gracefully.
To install .NET via snap, run the commands below:
sudo apt install snap sudo snap install dotnet-sdk --classic
After installing, you can begin building great applications.
That should do it!
This post showed you how to install .NET SDK on Ubuntu 20.04 | 18.04. If you find any error above, please use the comment form below to report.
You may also like the post below: