How To Install Dotnet 5, 6 and 3.1 Application.


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

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 -O packages-microsoft-prod.deb
Download the microsoft-prod.deb for dotnet-sdk

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

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

Check the version of the dotnet to be certain it installed.

$ dotnet --version
Check the version for dotnet-sdk

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
let’s install dotnet-sdk-6

Here, we will install the gpg package.

$ sudo apt-get install -y gpg

Thereafter, we will download the microsoft package with wget utility

$ sudo wget -O - | sudo gpg --dearmor -o microsoft.asc.gpg

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

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{os-version}/prod.list

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

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

We also change the ownership of the mircrosoft-prod.list to root.

$ sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

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 &amp;&amp; \<br>sudo apt-get install -y dotnet-sdk-6.0
Update and install dotnet-sdk

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

You can also uninstall dotnet-sdk-6.0 and all it dependencies by running the apt-get remove –purge command.

$ sudo apt-get update &amp;&amp; sudo apt-get remove --purge dotnet-*-6*
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 &amp;&amp; sudo apt-get install -y dotnet-sdk-3.1
  1. 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
    $ sudo dpkg -i ./libssl1.1_1.1.0g-2ubuntu4_amd64.deb
    $ rm -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
  1. 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
  2. ERROR: gpg: can’t create ‘microsoft.asc.gpg’: Permission denied
    SOLUTION: add sudo after the | in the command
    sudo wget -O – | sudo gpg –dearmor -o microsoft.asc.gpg
  3. 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.e
    wget "{os-version}/prod.list"
    wget ""
  4. 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.
  5. 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

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