Before I upgraded to Ubuntu 22.04 (Jammy), I had dotnet 5 and 6 installed, rather out of interest, than doing any serious programming.
As far as I can remember, I originally had installed the Snap version of dotnet, but had troubles installing any dotnet packages or templates, so I had switched to the “native” version of dotnet, probably using the
dotnet-install.sh variant – I’m not sure.
Upgrading to 22.04 seems to have uninstalled dotnet 5, as it is out of support, and weird things happened to the dotnet 6 installation:
dotnet new -i Avalonia.Templates
did not install the expected templates, but rather immediately returned the error message
The application ‘new’ does not exist
Further, the command
dotnet --info listed two 6.0 runtimes, but did not know of any previously installed SDKs.
After uninstalling and re-installing and uninstalling the
dotnet6 package, the command
dotnet was still there, but did not do anything useful.
$ dotnet --list-sdks
A fatal error occurred. The folder [/usr/lib/dotnet/dotnet6-6.0.108/host/fxr] does not exist
This can happen if
So I queried apt for the list of installed dotnet packages
$ apt list | grep dotnet WARNING: apt does not have a stable CLI interface. Use with caution in scripts. dotnet-apphost-pack-5.0/now 5.0.17-1 amd64 [installed,local] dotnet-apphost-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable] dotnet-host/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 [upgradable from: 6.0.108-0ubuntu1~22.04.1] dotnet-hostfxr-5.0/now 5.0.17-1 amd64 [installed,local] dotnet-hostfxr-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable] dotnet-runtime-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 dotnet-runtime-deps-5.0/now 5.0.17-1 amd64 [installed,local] dotnet-sdk-6.0-source-built-artifacts/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 dotnet-sdk-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 dotnet-targeting-pack-5.0/now 5.0.0-1 amd64 [installed,local] dotnet-targeting-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable] dotnet-templates-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable] dotnet6/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 libgtk-dotnet3.0-cil-dev/jammy 2.99.3-4build1 amd64 libgtk-dotnet3.0-cil/jammy 2.99.3-4build1 amd64
So I manually uninstalled all remaining dotnet packages
$ sudo apt-get remove dotnet-hostfxr-5.0 $ sudo apt autoremove
dotnet command was no longer recognized. From this clean state, I ran
$ sudo apt install dotnet6
and got a brand-new dotnet 6 environment and even a
$ dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.109 Commit: 58a93139d8 Runtime Environment: OS Name: ubuntu OS Version: 22.04 OS Platform: Linux RID: ubuntu.22.04-x64 Base Path: /usr/lib/dotnet/dotnet6-6.0.109/sdk/6.0.109/ global.json file: Not found Host: Version: 6.0.9 Architecture: x64 Commit: 163a63591c .NET SDKs installed: 6.0.109 [/usr/lib/dotnet/dotnet6-6.0.109/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.NETCore.App]