This article describes steps one can take to install the newly released Microsoft .NET 7 on Ubuntu Linux.
Microsoft announced the release of .NET 7 with enhanced Linux and native ARM64 support. The release brings your apps increased performance and new features for C# 11/F# 7, .NET MAUI, ASP.NET Core/Blazor, Web APIs, WinForms, WPF, and more.
This is a Standard Term Support (STS) release with 18 months and features a new Base Class Library (BCL) which allows developers to use one SDK, one Runtime, and one set of base libraries to build many types of apps (Cloud, Web, Desktop, Mobile, Gaming, IoT, and AI).
Starting with Ubuntu Linux 22.04, .NET 6 packages are included in Ubuntu’s default repositories. So users can simply run the apt-get command to install .NET 6 packages.
.NET 7 packages are not yet included in Ubuntu’s repositories. However, it is conceivable that it will be included very soon.
How to install .NET 7 on Ubuntu Linux
As described above, Microsoft announced the release of .NET 7 with enhanced Linux and native ARM64 support.
Below is how to install it on Ubuntu Linux.
Install .NET 6
As mentioned above, users can simply run the commands below to install .NET 7 since it’s already included in Ubuntu’s repositories.
To install .NET 6, run the commands below.
sudo apt update sudo apt install dotnet6
The commands above will install all the SDK, runtime, and ASP.NET packages.
You can install each of the features separately using the commands below.
sudo apt install dotnet-sdk-6.0 sudo apt install dotnet-runtime-6.O sudo apt install aspnetcore-runtime-6.0
Install .NET 7
Since .NET 7 packages are not yet included in Ubuntu’s repositories, you must install the official Microsoft .NET repository.
First, run the commands below to add the Microsoft repository’s GPG key.
sudo apt install curl curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo dd of=/usr/share/keyrings/microsoft.gpg
Once the repository GPG key is installed, run the commands below to create a repository file for each version of Ubuntu.
For version 22.04:
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null
For version 20.04:
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/20.04/prod focal main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null
For version 18.04:
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/18.04/prod bionic main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null
After adding the repository’s key and file, run the commands below to install .NET 7.
sudo apt update sudo apt install dotnet-sdk-7.0 sudo apt install dotnet-runtime-7.0 sudo apt install aspnetcore-runtime-7.0
To see information about .NET, simply run the commands below.
That should output similar lines as below:
.NET SDK: Version: 7.0.100 Commit: e12b7af219 Runtime Environment: OS Name: ubuntu OS Version: 22.10 OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/7.0.100/ Host: Version: 7.0.0 Architecture: x64 Commit: d099f075e4 .NET SDKs installed: 7.0.100 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
That should do it!
This post showed you how to Microsoft install .NET 7 on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.