How install dotnet 8 on Ubuntu 22.04

In this tutorial I will show how install .Net SDK on Ubuntu 22.04 LTS



Updated: 6 December 2023


Install key

You need install a key. 

To add the Microsoft repository, you have to first download & install the key file.


sudo wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg


This command will download the key, and will save to ‘/etc/apt/keyrings’ directory.

Add the Microsoft repository for apt

Create a new file into path "/etc/apt/sources.list.d/microsoft.sources"

This will add microsoft repository.


sudo nano /etc/apt/sources.list.d/microsoft.sources


Paste this code into file:



Types: deb
URIs: https://packages.microsoft.com/ubuntu/22.04/prod/
Suites: jammy
Components: main
Architectures: amd64
Signed-By: /etc/apt/keyrings/microsoft.gpg


For Ubuntu 20.04, replace 22.04 with 20.04, and jammy with focal.


Install .Net

Install using this command. 

sudo apt install dotnet-sdk-8.0


You can check the new version installed using command. 



dotnet --version


UnInstall .Net



sudo apt remove --autoremove aspnetcore-runtime-8.0 dotnet-sdk-8.0 dotnet-runtime-8.0

And, remove the Microsoft repository by running the 2 commands below to delete sources and key files.



sudo rm /etc/apt/keyrings/microsoft.gpg



sudo rm /etc/apt/sources.list.d/microsoft.sources




Comments