How to uninstall .NET SDK previews and older versions when uninstall tool doesn't recognise them

Viewed 2660

I'd like to uninstall .NET 5 and .NET 6 previews - and just keep the latest .NET 6.

However, the uninstall utility only let me uninstall the version I'd like to keep.

Neither are the old versions present for removal in Settings/Apps & features (Windows 10).

All SDKs have been installed using proper install utility - no zip files - or by Visual Studio.

I have uninstalled Visual Studio - I use VSCode instead.

List of the current SDKs:

C:\>dotnet --list-sdks

5.0.400 [C:\Program Files\dotnet\sdk]
6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]
6.0.101 [C:\Program Files\dotnet\sdk]

List of uninstallable SDKs (using the uninstall utility):

C:\Program Files (x86)\dotnet-core-uninstall>dotnet-core-uninstall list

.NET Core SDKs:
  6.0.101  x64    [Used by Visual Studio. Specify individually or use --force to remove]

.NET Core Runtimes:

ASP.NET Core Runtimes:

.NET Core Runtime & Hosting Bundles:

C:\Program Files (x86)\dotnet-core-uninstall>dotnet-core-uninstall --version
1.5.255402+e07a3c995ec2d3cf449d37eb50c87e180da12544

Any hints on how to get rid of them is greatly appreciated.

1 Answers

I know this is a few months late, but this ended up being quite high up on Google, so just adding the answer here.

You can use the dotnet-core-uninstall tool, https://docs.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool?tabs=windows

And can run: dotnet-core-uninstall remove --all-previews-but-latest If you just want to remove the preview/keep .Net 5, your question was just to keep .Net 6, so you can use --all-below 6.0.101 --sdk

You can do a dry run by adding it to the command (dry-run and whatif are synonyms, you can use either): dotnet-core-uninstall whatif --all-below 6.0.101 --sdk

Related