Five Effective Strategies for Managing .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.
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
).
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.
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.
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.
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.
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.