|
| 1 | +--- |
| 2 | +title: Five Effective Strategies for Managing .NET Versions |
| 3 | +lead: From the command line to the a GUI tool to manage .NET versions |
| 4 | +date: 2024-12-13 |
| 5 | +image: |
| 6 | + src: /images/windows_update_1.jpg |
| 7 | +badge: |
| 8 | + label: Development |
| 9 | +tags: |
| 10 | + - csharp |
| 11 | + - .NET |
| 12 | + - advent |
| 13 | +ImageAttribution: Picture of <a href="https://unsplash.com/fr/@cbpsc1">Clint Patterson</a> on <a href="https://unsplash.com/fr/photos/macbook-pro-sur-table-en-bois-marron-yGPxCYPS8H4">Unsplash</a> |
| 14 | +--- |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +::callout{icon="i-heroicons-light-bulb"} |
| 19 | +You can check the supported and unsupported versions of .NET [here](https://dotnet.microsoft.com/en-us/download/visual-studio-sdks) and learn more about how .NET is versioned [here](https://learn.microsoft.com/en-us/dotnet/core/versions/). |
| 20 | +:: |
| 21 | + |
| 22 | +## 1 - Create a script to remove old versions of .NET |
| 23 | + |
| 24 | +With the `dotnet --list-sdks` command you can display the installed SDKs (same thing for installed runtimes with the command `dotnet --runtimes`). |
| 25 | + |
| 26 | +{.rounded-lg .mx-auto width=800} |
| 27 | + |
| 28 | +So it’s not too complicated to make a script to uninstall these. It will help you free some space! |
| 29 | + |
| 30 | +## 2 - Use the .NET Uninstall Tool |
| 31 | + |
| 32 | +Instead of doing your own script, you can use the [.NET Uninstall Tool](https://learn.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool-overview) that Microsoft created to clean up .NET SDKs and Runtimes on a machine. |
| 33 | + |
| 34 | +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. |
| 35 | + |
| 36 | +{.rounded-lg .mx-auto width=1000} |
| 37 | + |
| 38 | +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. |
| 39 | + |
| 40 | +## 3 - Use Visual Studio installer |
| 41 | + |
| 42 | +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. |
| 43 | + |
| 44 | +{.rounded-lg .mx-auto width=1000} |
| 45 | + |
| 46 | +## 4 - Use a package manager like winget |
| 47 | + |
| 48 | +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? |
| 49 | + |
| 50 | +For Mac or Linux, you can use homebrew for instance. For Windows I like to use winget. |
| 51 | + |
| 52 | +{.rounded-lg .mx-auto width=1000} |
| 53 | + |
| 54 | +With the following command `winget install Microsoft.DotNet.SDK.9`, I can install the .NET 9 SDK. |
| 55 | + |
| 56 | +## 5 - Use Dots the friendly .NET SDK manager |
| 57 | + |
| 58 | +[Dots](https://github.com/nor0x/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. |
| 59 | + |
| 60 | +{.rounded-lg .mx-auto width=1000} |
| 61 | + |
| 62 | +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. |
0 commit comments