DEV Community

Cover image for Removing old version of .NET
Emanuele Bartolesi
Emanuele Bartolesi

Posted on


Removing old version of .NET

.NET Runtime updates are compatible with the latest major version of the .NET SDKs.
This means that you can remove safely the older versions.

You can see the current SDKs and runtimes are installed on you machine with the following commands:

dotnet --list-sdks
dotnet --list-runtimes
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

To remove the unuseful version of the SDKs and runtimes, you can use the dotnet-core-uninstall tool.
It's not installed by default but you can download the installer from this link:

Once you've installed it, you can use the following command to see the list with the .NET SDKs and runtimes that can be removed.

dotnet-core-uninstall list
Enter fullscreen mode Exit fullscreen mode

Image description

You can also perform a what-if analysis of an uninstall. This command displays the output of an uninstall task, without performing that.

dotnet-core-uninstall whatif --all

Image description

At the end, if you are convinced of the result, you can perform the real uninstall command:

dotnet-core-uninstall remove --all-previews-but-latest
Enter fullscreen mode Exit fullscreen mode

For instance, this command removes .NET SDKs and runtimes marked as previews except the one highest preview.

I use this command every month. I have a task on my calendar to remind me this important task.
A clean machine is a quick machine.

You can find all the commands and all the options in the official documentation at this link:

Happy cleaning!

Top comments (1)

gendalv profile image

doesn't work for 5.0.10

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git