Background
Dotnet Software Development Kit (dotnet-sdk) or .NET is a free and open-source project, developed and maintained on GitHub. It a popular because it performs faster than any other popular framework, according to TechEmpower. It supports build on platforms, including Windows, Linux, and macOS.
Due to it’s wide community support, simplicity in handling complex tasks, and security features, dotnet is becoming the de-facto programming language for building backend applications. I personally enjoy deploying dotnets applications and I have deployed tons of them (thanks to Sam and Mishael – dotnet seniors – they made me really love .NET).
In this walkthrough, we will see how to install the 3 widely used dotnet version i.e 5, 6, and 3.1.
NOTE: As at the time of writing, the dotnet 5 has reach the End of Life and no longer recieves security support from the dotnet community. However, we will for the sake of learning install the dotnet version.
Installing dotnet-sdk-5.0
We begin by adding the libicu package.
$ sudo apt-get install -y libicu-dev
![Install the libicu for dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/1-5.png?resize=648%2C27&ssl=1)
Add then, we download the Microsoft package signing key to the list of trusted keys and add the package repository. We use the wget utility to download this keys.
$ sudo wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
![Download the microsoft-prod.deb for dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/2-5.png?resize=665%2C221&ssl=1)
Now, we run the dpkg to depakage the downloaded microsoft packages.
$ sudo dpkg -i packages-microsoft-prod.deb
![depackage the microsoft-prod.deb for dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/3-6.png?resize=649%2C100&ssl=1)
The above steps prepared our server to install the dotnet application. Now, we will install the dotnet-sdk-5 on our server, but not first without installing the transport-https package.
$ sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-5.0
![Update and install dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/4-7.png?resize=666%2C67&ssl=1)
Check the version of the dotnet to be certain it installed.
$ dotnet --version
![Check the version for dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/5-7.png?resize=649%2C34&ssl=1)
You can uninstall dotnet package using the remove and –purge flag. Confirm the process with a Y when prompted.
$ sudo apt-get remove --purge dotnet-*5*
![Uninstall and purge the dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/6-6.png?resize=667%2C311&ssl=1)
let’s install dotnet-sdk-6
Here, we will install the gpg package.
$ sudo apt-get install -y gpg
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/7-6.png?resize=652%2C61&ssl=1)
Thereafter, we will download the microsoft package with wget utility
$ sudo wget -O - https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o microsoft.asc.gpg
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/8-4.png?resize=648%2C208&ssl=1)
For dotnet-6 to work properly, we will move the microsoft.asc.gpg package into the trusted.gpg directory in our apt directory.
$ sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/9-4.png?resize=657%2C34&ssl=1)
Once that is done, we will download prod.list from the microsoft packages repository for the version of Ubuntu server we have. Note that I have used 20.04 as the version here. Change the version to your own Ubuntu server version if you are using a different version.
$ sudo wget https://packages.microsoft.com/config/ubuntu/{os-version}/prod.list
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/10-3.png?resize=673%2C83&ssl=1)
Now, let’s also move the prod.list file into the microsoft-prod.list directory in the apt directory.
$ sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/11-3.png?resize=664%2C37&ssl=1)
We need to change the ownership of microsoft.asc.gpg to root. So, let’s do that.
$ sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/12-3.png?resize=664%2C37&ssl=1)
We also change the ownership of the mircrosoft-prod.list to root.
$ sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/13-2.png?resize=658%2C32&ssl=1)
Once we have done the above steps, we need to update the apt repository of the server to pick up our changes. Thereafter, we will install our dotnet-sdk-6.0 package.
$ sudo apt-get update && \<br>sudo apt-get install -y dotnet-sdk-6.0
![Update and install dotnet-sdk](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/14-2.png?resize=810%2C21&ssl=1)
You will be prompted to confirm the installation, enter Y at the prompt. Once the installation is complete, check the dotnet version to be certain installation is successful.
$ dotnet --version
![check dotnet version](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/15-1.png?resize=672%2C34&ssl=1)
You can also uninstall dotnet-sdk-6.0 and all it dependencies by running the apt-get remove –purge command.
$ sudo apt-get update && sudo apt-get remove --purge dotnet-*-6*
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/17-1.png?resize=673%2C36&ssl=1)
Install Dotnet-sdk-3.1
Installing dotnet-sdk-3.1 on Ubuntu server is pretty much the same as installing the dotnet-sdk-6.0. The slight difference is at the last step where you replace the dotnet-sdk-6.0 with dotnet-sdk-3.1 and you will have it installed.
$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-3.1
![](https://i0.wp.com/oxla.io/wp-content/uploads/2023/03/16-1.png?resize=668%2C37&ssl=1)
troubleshooting
- ERROR: The following packages have unmet dependencies:
dotnet-runtime-deps-5.0 : Depends: libssl1.0.0 but it is not installable or
libssl1.0.2 but it is not installable or
libssl1.1 but it is not installable
SOLUTION: This is due to the missing libsl dependency. To resolve download and install the libsl from the ubuntu archive.$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
$ sudo dpkg -i ./libssl1.1_1.1.0g-2ubuntu4_amd64.deb
$ rm -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
- ERROR: A fatal error occurred. The folder [/usr/lib/dotnet/dotnet6-6.0.109/host/fxr] does not exist
SOLUTION: Uninstall and Reinstall the dotnet package. If it seems not resolved after reinstalling, do apt update.$sudo apt update
$sudo apt upgrade - ERROR: gpg: can’t create ‘microsoft.asc.gpg’: Permission denied
SOLUTION: addsudo
after the | in the command
sudo wget -O – https://packages.microsoft.com/keys/microsoft.asc | sudo gpg –dearmor -o microsoft.asc.gpg - ERROR: HTTP request sent, awaiting response… 404 Not Found
2022-09-15 14:05:08 ERROR 404: Not Found.
This happens when you wget the package without putting the ubuntu version
SOLUTION: Add the OS version in the wget url. i.ewget "https://packages.microsoft.com/config/ubuntu/{os-version}/prod.list"
wget "https://packages.microsoft.com/config/ubuntu/22.04/prod.list" - ERROR: You intended to execute a .NET application: The application ‘-v’ does not exist.
This happens when you try to run any dotnet command.
SOLUTION: Purge the dotnet installations. Then reinstall. You can also follow the post here to resolve. - ERROR: A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
SOLUTION: This happened when you check the dotnet version on a newly installed dotnet. It is caused when there is conflict in the dotnet package manager to use inside the server. You can resolve by using one of either microsoft or ubuntu package. I did a full post to resolve this issue. Check it out here.
Leave a Reply