Developers wishing to develop .NET applications on Ubuntu, the first thing to do is to install the .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 a cross-platform and open-source framework. It now supports Linux and MacOS systems out of the box. It is also modular and lightweight
To get started with installing the .NET SDK on Ubuntu, follow the steps below:
Install required package
To do this, be sure to install Apt-transport-https Package using the below command.
sudo apt update sudo apt install apt-transport-https
Add .NET Repository
Now that the package has been installed above, run the below command 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 only be able to install .NET by running the commands below.
sudo apt update sudo apt install dotnet-sdk-5.0
After installing, you should get a successful message like 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 above command will display the installed version of .NET.
Output: 5.0.202 [/usr/share/dotnet/sdk]
Also verify that the .NET runtime is working.
The same lines should be displayed 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
Snap There are containerized software packages that are easy to create and install.
Snap applications are packed with all their dependencies so that they can run on all popular Linux distributions from a single build that allows them to automatically update and roll back gracefully.
To install .NET via snap, run the following command:
After installing, you can start creating great applications.
You may also like the post below: