Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet-core-uninstall not working from command line

I am working through the book C# 9.0 and .NET 5. On the section titled 'Removing old versions of .NET' it has several commands to make sure the most recent version is used.

dotnet --list-sdks

dotnet --list-runtimes

both work fine.

However, when I run the command dotnet-core-uninstall --all-previews-but-latest --sdk I receive the error message that dotnet-core-uninstall isn't the name of a cmdlet, function, script file or operable program.

If I adjust the command from what is in the book to: dotnet -core-uninstall I get the message 'unknown option: -core-uninstall' followed by the same output as dotnet --help

Likewise, if I run dotnet -core-uninstall --all-previews-but-latest --sdk the output tells me that -core-uninstall, --all-previews-but-latest and --sdk are unknown options.

I then tried running these commands from the visual studio terminal, and had no luck either. Any help is greatly appreciated!

like image 716
riemann_lebesgue Avatar asked Oct 19 '25 03:10

riemann_lebesgue


1 Answers

dotnet-core-uninstall is a separate experimental tool, not part of the .NET Core SDK. You need to download from its Github repo and install it.

The tool isn't a Global Tool because it wouldn't be able to remove the runtime it's running on. As the repo README explains:

Since .NET Core Global Tools are runtime-dependent applications they use a version of the .NET Core Runtime that is installed on the machine. The purpose of the tool is to uninstall arbitrary .NET Core SDKs and Runtimes, so may attempt to uninstall the version that’s running the current process. When this happened, we didn’t find a way to recover from the error and uninstall other SDKs and Runtimes. We saw this as particularly problematic because users might not be clear what runtimes are in SDKs that are being uninstalled or which runtime is currently being used.

You may have installed a NET 6 preview for example and want to remove it. If dotnet-core-uninstall was a global tool, it would use the .NET 6 Preview runtime and wouldn't be able to remove it

like image 101
Panagiotis Kanavos Avatar answered Oct 21 '25 19:10

Panagiotis Kanavos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!