Five Effective Strategies for Managing .NET Versions

From the command line to the a GUI tool to manage .NET versions

With a new .NET version released each year, an LTS version every three years, and regular patches, you likely have multiple .NET SDK versions installed on your computer. Some may need updating, while others should be removed because they are no longer supported. In this article, we will explore 5 effective ways to manage your .NET SDK versions.

💡
You can check the supported and unsupported versions of .NET here and learn more about how .NET is versioned here.

1 - Create a script to remove old versions of .NET

With the dotnet --list-sdks command you can display the installed SDKs (same thing for installed runtimes with the command dotnet --runtimes).

Command line interface displaying installed .NET SDK versions: 6.0.201, 6.0.302, 8.0.303, and 9.0.101 with their corresponding installation paths.

So it’s not too complicated to make a script to uninstall these. It will help you free some space!

2 - Use the .NET Uninstall Tool

Instead of doing your own script, you can use the .NET Uninstall Tool that Microsoft created to clean up .NET SDKs and Runtimes on a machine.

With the dotnet-core-uninstall list command, you can see the .NET versions that can be uninstalled. As you can see, it also identifies which versions are used by Visual Studio.

Command line interface displaying a tool for uninstalling specific versions of .NET Core SDKs, Runtimes, and Hosting Bundles, with a list of available versions that can be uninstalled.

You can then uninstall .NET versions using the dotnet-core-uninstall remove command which has interesting options like --all-but to remove all .NET SDKs and runtimes except the ones specified.

3 - Use Visual Studio installer

If you are using Visual Studio, updating it to the latest version will automatically update the .NET versions too. You can also use the installer to add specific .NET versions in the individual components section.

The image shows the Visual Studio Installer interface, focusing on the "Individual components" tab. Several .NET runtimes and SDKs are listed with checkboxes. Among them, .NET 6.0 Runtime (Long Term Support), .NET 7.0 Runtime, .NET 8.0 Runtime (Long Term Support), .NET 9.0 Runtime, and .NET Aspire SDK are checked. Some runtimes are marked as "Out of support."

4 - Use a package manager like winget

The easiest way to manage your .NET versions is by using a package manager. This is likely how you already handle your other software and tools, so why not use it for .NET SDKs and runtimes too?

For Mac or Linux, you can use homebrew for instance. For Windows I like to use winget.

A command-line interface displays search and list results for Microsoft .NET SDKs using the  tool. The search results show different versions from SDK 3.1 to 9.0 Preview, while the list shows installed versions 6.0.302 and 8.0.303.

With the following command winget install Microsoft.DotNet.SDK.9, I can install the .NET 9 SDK.

5 - Use Dots the friendly .NET SDK manager

Dots is my latest discovery, which I found while looking for a way to uninstall old .NET versions, and it's fantastic. It's an open-source project that offers a GUI to search, install, and uninstall SDKs. What I love about it is that you can see a lot of useful information about the versions, such as their support status, whether they are LTS, and if they are already installed. There are also filters to quickly see which versions you should update or cleanup.

A software management interface displays various versions of .NET, including 9.0.101 and earlier previews. Each version has options to download, install, or uninstall. Details for version 9.0.101 include release notes, release date, and supported languages like C#. Download links for different Linux architectures are available.

To summarize, there are various ways to manage your .NET SDK versions. This can help free up space and ensure your system is up-to-date with supported versions. Using a package manager like winget is my preferred method for managing .NET versions. However, other tools like Dots or the .NET Uninstall tool can also be very helpful at times.

This article was published as part of the C# Advent 2024 which is a nice initiative. Make sure to check the other blog articles on the advent calendar.