How to download dotnet-sdk-2.2 on ubuntu 20.04 focal?

6.6k Views Asked by At

I've been trying to download netcore 2.2 on ubuntu, Ive tried with apt and I have no luck I get the package not found error.

I also tried downloading the binaries and registering the path but it doesn't seem to work. Is it just not possible at all?

4

There are 4 best solutions below

0
On

First must read very very clear answer for @amajid.

About point #4 In case you already install another SDKs like Dotnet SDK 3.1 or 2.1 (supported SDKs on Ubuntu 20.04), you can install manual Dotnet SDK 2.2 on the default location of another SDKs [under /usr/share/dotnet folder] like comment under @omajid answer by @Soran

sudo tar xf dotnet-sdk-2.2.207-linux-x64.tar.gz -C /usr/share/dotnet

after extract Dotnet SDK Must make sure all folders and files with root user and root group

sudo chown -R root /usr/share/dotnet
sudo chgrp -R root /usr/share/dotnet 

Finally I would like to mention about installing Dotnet SDK 2.2 on Ubuntu 20.04 manually will complete and work But you will face some problems (which I already faced)

1- You not able to Run Publish command with Ubuntu 20.04 Runtime as framework not support this runtime

 dotnet publish -c Release -r ubuntu.20.04-x64 --self-contained

2- You face problem on Permission denied error on NuGetFallbackFolder file every you use dotnet command, Github issue

1
On

In my case, I already had versions installed through APT.

As I had to work on some projects that still use .NET Core 2.2, I just copied the contents of the $HOME/dotnet/sdk/2.2.207 (this version may be different on your machine) and $HOME/dotnet/shared/* folders to /usr/share/dotnet.

With bash, I've used this commands:

sudo cp -r ~/dotnet/sdk/* /usr/share/dotnet/sdk/
sudo cp -r ~/dotnet/host/* /usr/share/dotnet/host/
sudo cp -r ~/dotnet/shared/* /usr/share/dotnet/shared/
1
On

.NET Core 2.2 was End of Life'd in Dec 2019. So Microsoft doesn't produce packages .NET Core 2.2 for recent versions of Linux distributions, including Ubuntu 20.04. Only 2.1 and 3.1, the currently supported versions, are available for Ubuntu 20.04.

If you want to install them, you should try a manual install:

  1. Go to the main download site: https://dotnet.microsoft.com/download/dotnet-core

  2. Click "Out of support versions". That should show you a table. Click on 2.2, which should take you to: https://dotnet.microsoft.com/download/dotnet-core/2.2

  3. Click on the "x64" under the "Binaries" table of the release: https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-2.2.207-linux-x64-binaries

  4. Follow the steps on that page to extract the downloaded tarball and "install" it:

    mkdir -p $HOME/dotnet && tar xf dotnet-sdk-2.2.207-linux-x64.tar.gz -C $HOME/dotnet
    export DOTNET_ROOT=$HOME/dotnet
    export PATH=$PATH:$HOME/dotnet
    

I am going to repeat the warnings you will see on the download site: This is an old version of .NET Core which has many unpatched security vulnerabilities that are now public. You do not want to deploy an application to production using .NET Core 2.2. Upgrade to 3.1 or downgrade to 2.1 instead.

2
On

I had the same issue. This what I did:

sudo apt-get install -y gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/ubuntu/20.04/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2