I went to the following official Microsoft link to install .NET Core 6.x (SDK & runtime) and they would not work.

Basically, it tells you to :

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Then to install SDK you are supposed to run:

sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0

Then to install runtime it says to run:

sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-6.0

But when I ran all of that, I got a weird thing where the runtime was "half installed".

I could run $ dotnet --list-sdks and it wouldn't report any SDK.

Also, I couldn't run the simple command $ dotnet --version It would state that no SDKs were installed and the command couldn't run. Very confusing.

I also got an error like:

Unable to locate package dotnet-sdk-6.0

Microsoft says to choose the following link to resolve that: APT troubleshooting section.

Tried Snap I also tried installing the snap. Again, dotnet runtime still didn't work properly. I tried various removing and rebooting and many options but could never get the SDK installed properly.

3 Answers 3


I make it run with the APT package solution, in fact there is a conflict between Ubuntu packages (Jammy feed) and Microsoft Package (PMC), more info here: https://github.com/dotnet/core/issues/7699

The solution with the following steps works for me: Use .NET 6 Package via PMC

  1. Remove all .NET packages
sudo apt remove 'dotnet*'
sudo apt remove 'aspnetcore*'
  1. Create the file:
sudo touch /etc/apt/preferences.d/dotnet.pref

with content:

Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
  1. Install .NET SDK 6.0
sudo apt update
sudo apt install dotnet-sdk-6.0

And I got the last version of the SDK:

$ dotnet --list-sdks
6.0.400 [/usr/share/dotnet/sdk]
  • Thank you, worked like a charm on Ubuntu 22.04! I used specific version to install: sudo apt install dotnet-sdk-6.0=6.0.301 Aug 20, 2022 at 11:02

Only Manual Install Works

I finally installed .NET Core 6.x SDK & runtime manually, by following the steps at: https://docs.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#manual-install

I downloaded .NET Core 6.x SDK & runtime tar gz.

Next, I opened a terminal and I ran each of the following, one at a time:

$ DOTNET_FILE=dotnet-sdk-6.0.400-linux-x64.tar.gz
$ export DOTNET_ROOT=$(pwd)/.dotnet
$ mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"

Right after I did that I was able to run:

$ dotnet --version and I saw the appropriate output: 6.0.400

Next, I tried listing the SDKS:

$ dotnet --list-sdks and I saw: 6.0.400 [/home/raddev/Downloads/.dotnet/sdk]

I built a sample program and ran it and now everything works.

It seems you have to manually do this install.

After that I had to edit my ~/.bashrc and add the two following lines as the last two lines, so that appropriate folders would always be available via path.

export PATH=$PATH:$HOME/.dotnet
export DOTNET_ROOT=$HOME/.dotnet

Update (2022-08-16)

This article was just released today: Microsoft and Canonical announce native .NET availability in Ubuntu 22.04 hosts and containers -- Sub-title Install .NET 6 with one apt install command.

Here's the main point:

install .net on 22.04

  • The top-voted solution works perfectly. Without package pinning, even the later update in this solution does not work.
    – Auspex
    Sep 8, 2022 at 16:18

The following simple command has fixed the problem for me:

sudo apt dist-upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.