Installing Microsoft .NET 7 on Ubuntu Linux: A Step-by-Step Guide

Installing Microsoft .NET 7 on Ubuntu Linux A Step-by-Step Guide

Microsoft .NET is a popular software framework that is widely used for developing applications on the Windows operating system. However, it is also possible to install and run .NET on Linux, including the Ubuntu distribution. In this article, we will provide a step-by-step guide on how to install .NET 7 on Ubuntu Linux.

Microsoft has just released .NET 7, the latest version of its popular software development platform. This release comes with a host of new features and enhancements, including enhanced Linux and native ARM64 support, which will result in improved performance for your apps. Developers can now use the latest version of C# 11 and F# 7, as well as new tools like .NET MAUI, ASP.NET Core/Blazor, Web APIs, WinForms, WPF and more.

This is a Standard Term Support (STS) release, meaning it will be supported for 18 months. Additionally, with the new Base Class Library (BCL), developers will be able to use a single SDK, Runtime, and set of base libraries to build a wide variety of applications, including cloud, web, desktop, mobile, gaming, IoT and AI.

For Ubuntu Linux 22.04 users, .NET 6 packages are already included in Ubuntu’s default repositories, making it easy to install. While .NET 7 packages are not yet included in Ubuntu’s repositories, it is expected that they will be soon. This makes it easy for developers using Ubuntu Linux to start building applications using the latest version of .NET.


How to Install the latest version .NET 7 on Ubuntu Linux

Installing .NET 7 on Ubuntu Linux can seem like a daunting task, but it’s actually quite simple when you know the steps.

Step 1: Install .NET 6

Before installing .NET 7, it is essential to have .NET 6 already installed on your system. To do so, please execute the following commands:

sudo apt update
sudo apt install dotnet6
sudo apt-get install dotnet-sdk-6.0
sudo apt-get install dotnet-runtime-6.0
sudo apt-get install aspnetcore-runtime-6.0

Step 2: Install .NET 7

As .NET 7 packages are not yet included in Ubuntu’s official repositories, it is required to install the official Microsoft .NET repository. To do so, please perform the following actions:

1. Add the Microsoft repository’s GPG key by executing the following command:

sudo apt install curl
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo dd of=/usr/share/keyrings/microsoft.gpg

2. Create a repository file for the version of Ubuntu you are using by executing the appropriate command:

For Ubuntu 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

And For Ubuntu 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 Ubuntu 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

3. Install .NET 7 by executing the following commands:

sudo apt update
sudo apt install dotnet-sdk-7.0
sudo apt install dotnet-runtime-7.0 
sudo apt install aspnetcore-runtime-7.0

Step 3: Verify the Installation:

To verify the installation, you can run the following command to check the version of .NET installed:

dotnet --info

The output of the command dotnet --info will provide information about the version of the .NET SDK and runtime that are currently installed on your system. The exact output will depend on the version of .NET that you have installed, but it will generally include the following information:

.NET Core SDK (reflecting any global.json):
 Version: 7.0.0
 Commit:  0000000000000000000000000000000000000000

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.0/

Host (useful for support):
  Version: 7.0.0
  Commit:  0000000000000000000000000000000000000000

.NET Core SDKs installed:
  7.0.0 [/usr/share/dotnet/sdk]

.NET Core 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]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

This output will show you the version of the SDK and runtime that are currently installed, as well as the version of the OS and architecture that you are running. It also includes information about the specific version of the SDK and runtime that are installed. Additionally, it shows you the path where the SDKs and runtimes are installed on the system and the commit id of the version you have installed. At the end, it also includes a link to the official website where you can download additional versions of the .NET Core SDKs or runtimes.


Conclusion:

By following the above-mentioned steps, you will have successfully installed .NET 7 on your Ubuntu Linux system and be ready to start developing with the latest version of the .NET framework. The commands used in this guide are written in a way that is professional and clear, and easy to understand, making the installation process as seamless as possible.

We hope that this article has helped you to navigate Linux directories with greater ease and efficiency. If you found it useful, please share with others and leave us your feedback.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top