This document outlines steps for performing a deep clean on your Linux (Ubuntu 20.04) machine.
An example for performing could be, if your installation does not show in dotnet --list-sdks
. Performing this deep clean and reinstalling will solve it in most cases.
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-6.0
dotnet --list-sdks
sudo apt remove --purge dotnet-sdk-6.0
sudo apt remove --purge dotnet-runtime-6.0
sudo apt-get purge --auto-remove packagename
-- OR --
sudo apt list | grep "dotnet"
sudo apt-get remove - purge -y dotnet-runtime-6.0
sudo apt-get remove - purge -y dotnet-hostfxr-6.0
sudo apt-get remove - purge -y dotnet-runtime-deps-6.0
sudo apt-get remove - purge -y dotnet-targeting-pack-6.0
sudo apt-get remove --purge -y dotnet-apphost-pack-6.0
sudo apt-get remove --purge -y dotnet-host/now 6.0.0
sudo apt-get remove - purge -y dotnet-apphost-pack-6.0
https://stackoverflow.com/questions/73312785/dotnet-sdk-is-installed-but-not-recognized-linux-ubuntu-popos-22-04 dotnet/core#7699
sudo apt remove 'dotnet*'
sudo apt remove 'aspnetcore*'
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install dotnet-sdk-6.0
Install .NET 6 says "it installed" but something is wrong.
tester@MACHINE:~/VSLinuxDbg/Linux.Bluetooth.ManualTest$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 dotnet-apphost-pack-6.0 dotnet-hostfxr-6.0 dotnet-runtime-6.0 dotnet-targeting-pack-6.0
dotnet-templates-6.0 liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1
The following NEW packages will be installed:
aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 dotnet-apphost-pack-6.0 dotnet-hostfxr-6.0 dotnet-runtime-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0
dotnet-templates-6.0 liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1
0 upgraded, 11 newly installed, 0 to remove and 2 not upgraded.
Need to get 91.0 MB/122 MB of archives.
After this operation, 433 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-hostfxr-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [154 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 liblttng-ust-common1 amd64 2.13.1-1ubuntu1 [27.1 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 liblttng-ust-ctl5 amd64 2.13.1-1ubuntu1 [77.9 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 liblttng-ust1 amd64 2.13.1-1ubuntu1 [190 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 aspnetcore-targeting-pack-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [1,457 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-apphost-pack-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [3,702 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-targeting-pack-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [2,248 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-templates-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [2,586 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-sdk-6.0 amd64 6.0.119-0ubuntu1~22.04.1 [80.5 MB]
Fetched 91.0 MB in 3s (30.1 MB/s)
Selecting previously unselected package dotnet-hostfxr-6.0.
(Reading database ... 183503 files and directories currently installed.)
Preparing to unpack .../00-dotnet-hostfxr-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-hostfxr-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package liblttng-ust-common1:amd64.
Preparing to unpack .../01-liblttng-ust-common1_2.13.1-1ubuntu1_amd64.deb ...
Unpacking liblttng-ust-common1:amd64 (2.13.1-1ubuntu1) ...
Selecting previously unselected package liblttng-ust-ctl5:amd64.
Preparing to unpack .../02-liblttng-ust-ctl5_2.13.1-1ubuntu1_amd64.deb ...
Unpacking liblttng-ust-ctl5:amd64 (2.13.1-1ubuntu1) ...
Selecting previously unselected package liblttng-ust1:amd64.
Preparing to unpack .../03-liblttng-ust1_2.13.1-1ubuntu1_amd64.deb ...
Unpacking liblttng-ust1:amd64 (2.13.1-1ubuntu1) ...
Selecting previously unselected package dotnet-runtime-6.0.
Preparing to unpack .../04-dotnet-runtime-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package aspnetcore-runtime-6.0.
Preparing to unpack .../05-aspnetcore-runtime-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking aspnetcore-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package aspnetcore-targeting-pack-6.0.
Preparing to unpack .../06-aspnetcore-targeting-pack-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking aspnetcore-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package dotnet-apphost-pack-6.0.
Preparing to unpack .../07-dotnet-apphost-pack-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-apphost-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package dotnet-targeting-pack-6.0.
Preparing to unpack .../08-dotnet-targeting-pack-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package dotnet-templates-6.0.
Preparing to unpack .../09-dotnet-templates-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-templates-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Selecting previously unselected package dotnet-sdk-6.0.
Preparing to unpack .../10-dotnet-sdk-6.0_6.0.119-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-sdk-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up dotnet-apphost-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up liblttng-ust-common1:amd64 (2.13.1-1ubuntu1) ...
Setting up dotnet-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up aspnetcore-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up liblttng-ust-ctl5:amd64 (2.13.1-1ubuntu1) ...
Setting up dotnet-hostfxr-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up dotnet-templates-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up liblttng-ust1:amd64 (2.13.1-1ubuntu1) ...
Setting up dotnet-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up aspnetcore-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Setting up dotnet-sdk-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
As you can see, it's not there
tester@MACHINE:~/VSLinuxDbg/Linux.Bluetooth.ManualTest$ dotnet --list-sdks
5.0.408 [/usr/share/dotnet/sdk]
Running again, doesn't move very far
tester@MACHINE:~/VSLinuxDbg/Linux.Bluetooth.ManualTest$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
dotnet-sdk-6.0 is already the newest version (6.0.119-0ubuntu1~22.04.1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Let's check if where it is...
tester@MACHINE:/usr/share/dotnet$ ls -la /usr/lib/dotnet
total 36
drwxr-xr-x 9 root root 4096 Jun 29 17:38 .
drwxr-xr-x 102 root root 4096 Jun 29 16:54 ..
lrwxrwxrwx 1 root root 25 Oct 27 2022 dotnet6 -> /etc/alternatives/dotnet6
drwxr-xr-x 3 root root 4096 Jun 29 17:38 host
drwxr-xr-x 3 root root 4096 Jun 29 17:38 metadata
drwxr-xr-x 6 root root 4096 Jun 29 17:38 packs
drwxr-xr-x 3 root root 4096 Jun 29 17:38 sdk
drwxr-xr-x 3 root root 4096 Jun 29 17:38 sdk-manifests
drwxr-xr-x 4 root root 4096 Jun 29 17:38 shared
drwxr-xr-x 3 root root 4096 Jun 29 17:38 templates
Notice, only .NET 5.0 is found
tester@MACHINE:~/VSLinuxDbg/Linux.Bluetooth.ManualTest$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
dotnet-sdk-6.0 is already the newest version (6.0.119-0ubuntu1~22.04.1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Strangly, there is something in the home folder:
tester@MACHINE:~$ ls -la .dotnet
total 32
drwxrwxr-x 5 tester tester 4096 Jun 29 17:40 .
drwxr-x--- 20 tester tester 4096 Jun 29 17:41 ..
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.aspNetCertificateSentinel
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.dotnetFirstUseSentinel
-rw-rw-r-- 1 tester tester 5 Jul 26 2022 6.0.302_IsDockerContainer.dotnetUserLevelCache
-rw-rw-r-- 1 tester tester 64 Jul 26 2022 6.0.302_MachineId.dotnetUserLevelCache
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.toolpath.sentinel
drwxrwxr-x 3 tester tester 4096 Jul 26 2022 corefx
-rw-rw-r-- 1 tester tester 64 Jul 26 2022 MachineId.v1.dotnetUserLevelCache
drwxrwxr-x 3 tester tester 4096 Jun 29 17:40 optimizationdata
drwxrwxr-x 2 tester tester 4096 Jul 26 2022 TelemetryStorageService
=============================
Time to purge it all!!
$ sudo apt remove 'dotnet*'
$ sudo apt remove 'aspnetcore*'
Next, Deleted PMC repository from APT, by deleting the repo .list file
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
Installed .NET 6 SDK via
sudo apt install dotnet-sdk-6.0
=============================
tester@MACHINE:~$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.408
Commit: da985e2a23
Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/5.0.408/
Host (useful for support):
Version: 5.0.17
Commit: 6a98414363
.NET SDKs installed:
5.0.408 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
tester@MACHINE:~$ ls -la /usr/share/dotnet/sdk
total 20
drwxr-xr-x 3 root root 4096 Jun 29 16:37 .
drwxr-xr-x 7 root root 4096 Jun 29 16:55 ..
drwxr-xr-x 28 root root 12288 Jul 25 2022 5.0.408
tester@MACHINE:~$ ls -la /usr/share/dotnet
total 272
drwxr-xr-x 7 root root 4096 Jun 29 16:55 .
drwxr-xr-x 244 root root 12288 Jul 26 2022 ..
-rwxr-xr-x 1 root root 145880 Jun 18 19:54 dotnet
drwxr-xr-x 3 root root 4096 May 4 2022 host
-rw-r--r-- 1 root root 1116 Jun 18 19:54 LICENSE.txt
drwxr-xr-x 5 root root 4096 Oct 17 2022 packs
drwxr-xr-x 3 root root 4096 Jun 29 16:37 sdk
drwxr-xr-x 4 root root 4096 May 4 2022 shared
drwxr-xr-x 3 root root 4096 Jun 29 16:37 templates
-rw-r--r-- 1 root root 86282 Jun 18 19:54 ThirdPartyNotices.txt
tester@MACHINE:~$ ls -la .dotnet
total 32
drwxrwxr-x 5 tester tester 4096 Jun 29 17:40 .
drwxr-x--- 20 tester tester 4096 Jun 29 17:41 ..
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.aspNetCertificateSentinel
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.dotnetFirstUseSentinel
-rw-rw-r-- 1 tester tester 5 Jul 26 2022 6.0.302_IsDockerContainer.dotnetUserLevelCache
-rw-rw-r-- 1 tester tester 64 Jul 26 2022 6.0.302_MachineId.dotnetUserLevelCache
-rw-rw-r-- 1 tester tester 0 Jul 26 2022 6.0.302.toolpath.sentinel
drwxrwxr-x 3 tester tester 4096 Jul 26 2022 corefx
-rw-rw-r-- 1 tester tester 64 Jul 26 2022 MachineId.v1.dotnetUserLevelCache
drwxrwxr-x 3 tester tester 4096 Jun 29 17:40 optimizationdata
drwxrwxr-x 2 tester tester 4096 Jul 26 2022 TelemetryStorageService
tester@MACHINE:~$ sudo apt remove 'dotnet*'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'dotnet-hostfxr-5.0' for glob 'dotnet*'
Note, selecting 'dotnet-hostfxr-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-hostfxr-7.0' for glob 'dotnet*'
Note, selecting 'dotnet-sdk-5.0' for glob 'dotnet*'
Note, selecting 'dotnet-sdk-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-sdk-7.0' for glob 'dotnet*'
Note, selecting 'dotnet6' for glob 'dotnet*'
Note, selecting 'dotnet7' for glob 'dotnet*'
Note, selecting 'dotnet-targeting-pack-5.0' for glob 'dotnet*'
Note, selecting 'dotnet-targeting-pack-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-targeting-pack-7.0' for glob 'dotnet*'
Note, selecting 'dotnet-nightly' for glob 'dotnet*'
Note, selecting 'dotnet-templates-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-templates-7.0' for glob 'dotnet*'
Note, selecting 'dotnet-host-7.0' for glob 'dotnet*'
Note, selecting 'dotnet-host' for glob 'dotnet*'
Note, selecting 'dotnet-runtime-deps-5.0' for glob 'dotnet*'
Note, selecting 'dotnet' for glob 'dotnet*'
Note, selecting 'dotnet-sdk-6.0-source-built-artifacts' for glob 'dotnet*'
Note, selecting 'dotnet-apphost-pack-5.0' for glob 'dotnet*'
Note, selecting 'dotnet-apphost-pack-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-apphost-pack-7.0' for glob 'dotnet*'
Note, selecting 'dotnet-sdk-7.0-source-built-artifacts' for glob 'dotnet*'
Note, selecting 'dotnet-runtime-5.0' for glob 'dotnet*'
Note, selecting 'dotnet-runtime-6.0' for glob 'dotnet*'
Note, selecting 'dotnet-runtime-7.0' for glob 'dotnet*'
Package 'dotnet' is not installed, so not removed
Package 'dotnet-nightly' is not installed, so not removed
Package 'dotnet-apphost-pack-7.0' is not installed, so not removed
Package 'dotnet-host-7.0' is not installed, so not removed
Package 'dotnet-hostfxr-7.0' is not installed, so not removed
Package 'dotnet-runtime-7.0' is not installed, so not removed
Package 'dotnet-sdk-6.0-source-built-artifacts' is not installed, so not removed
Package 'dotnet-sdk-7.0' is not installed, so not removed
Package 'dotnet-sdk-7.0-source-built-artifacts' is not installed, so not removed
Package 'dotnet-targeting-pack-7.0' is not installed, so not removed
Package 'dotnet-templates-7.0' is not installed, so not removed
Package 'dotnet6' is not installed, so not removed
Package 'dotnet7' is not installed, so not removed
The following packages were automatically installed and are no longer required:
aspnetcore-targeting-pack-6.0 liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1 netstandard-targeting-pack-2.1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
aspnetcore-runtime-5.0 aspnetcore-runtime-6.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0 dotnet-apphost-pack-6.0 dotnet-host dotnet-hostfxr-5.0
dotnet-hostfxr-6.0 dotnet-runtime-5.0 dotnet-runtime-6.0 dotnet-runtime-deps-5.0 dotnet-sdk-5.0 dotnet-sdk-6.0 dotnet-targeting-pack-5.0
dotnet-targeting-pack-6.0 dotnet-templates-6.0
0 upgraded, 0 newly installed, 16 to remove and 2 not upgraded.
After this operation, 796 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 186652 files and directories currently installed.)
Removing dotnet-sdk-5.0 (5.0.408-1) ...
Removing aspnetcore-runtime-5.0 (5.0.17-1) ...
Removing dotnet-sdk-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing aspnetcore-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing aspnetcore-targeting-pack-5.0 (5.0.0-1) ...
Removing dotnet-apphost-pack-5.0 (5.0.17-1) ...
Removing dotnet-apphost-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing dotnet-runtime-5.0 (5.0.17-1) ...
Removing dotnet-hostfxr-5.0 (5.0.17-1) ...
Removing dotnet-templates-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing dotnet-runtime-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing dotnet-hostfxr-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing dotnet-runtime-deps-5.0 (5.0.17-1) ...
Removing dotnet-targeting-pack-5.0 (5.0.0-1) ...
Removing dotnet-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...
Removing dotnet-host (7.0.8-1) ...
Processing triggers for man-db (2.10.2-1) ...
tester@MACHINE:~$ sudo apt remove 'aspnetcore*'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'aspnetcore-runtime-6.0' for glob 'aspnetcore*'
Note, selecting 'aspnetcore-runtime-7.0' for glob 'aspnetcore*'
Note, selecting 'aspnetcore-targeting-pack-6.0' for glob 'aspnetcore*'
Note, selecting 'aspnetcore-targeting-pack-7.0' for glob 'aspnetcore*'
Package 'aspnetcore-runtime-6.0' is not installed, so not removed
Package 'aspnetcore-runtime-7.0' is not installed, so not removed
Package 'aspnetcore-targeting-pack-7.0' is not installed, so not removed
The following packages were automatically installed and are no longer required:
liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1 netstandard-targeting-pack-2.1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
aspnetcore-targeting-pack-6.0
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
After this operation, 12.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 180698 files and directories currently installed.)
Removing aspnetcore-targeting-pack-6.0 (6.0.119-0ubuntu1~22.04.1) ...