In my case despite installing dotnet-sdk-7.0
and dotnet --version
command returning correct version, I've been seeing no SDK in dotnet --info
.
The problem was that I had dotnet packages installed from different sources. There are a few sources you can download dotnet package: official Ubuntu feed and Microsoft feed. I wanted to use Microsoft feed, as it provided newer versions of dotnet for my distro version, but actually used both.
Here is how you can list all your dotnet packages:
sudo apt list --installed | grep dotnet
Here is how you can check source of your packages:
sudo apt policy dotnet-sdk-7.0
How to fix it
You just need to follow this docs. You need to get rid of official Ubuntu packages and install all of them from one source.
So:
Remove all dotnet packages:
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
Create files for apt preferences:
touch /etc/apt/preferences
Inside this file, paste this text. It will configure APT to ignore packages with those names in specific package source:
Package: dotnet* aspnet* netstandard*
Pin: origin "<your-package-source>"
Pin-Priority: -10
So if you configure it like this:
Package: dotnet* aspnet* netstandard*
Pin: origin "archive.ubuntu.com"
Pin-Priority: -10
It will ignore packages from archive.ubuntu.com
. So when you install dotnet-sdk-7.0
again, it will omit archive.ubuntu.com
and install it from Microsoft source.
You may have different package sources, depending on distro, you can check it like this:
sudo cat /etc/apt/sources.list.d/official-package-repositories.list