The Microsoft .NET family is released in parallel channels by Microsoft. This means that one major version can coexist with another and that installing e.g. 6.x doesn't replace 5.x.
Microsoft .NET uninstall tool, this can be used to manage .NET installations, however, care must be taken, as it can remove more versions than intended. Fortunately, redeploying .NET is easy, as we also support installing it as a deployment job:
You will need to deploy the Microsoft .NET uninstall tool on each host where you want to handle the various .NET versions.
Once you have the uninstall tool installed on the hosts, you can use Custom Software to create a custom job for the uninstall tool, where you will attach a .ps1 script as the Installer, which contains the following:
Start-Process -FilePath "C:\Program Files (x86)\dotnet-core-uninstall\dotnet-core-uninstall.exe" -ArgumentList "remove --all-but-latest --runtime --yes" -WorkingDirectory "C:\Program Files (x86)\dotnet-core-uninstall"
The above example should remove all RUNTIME versions except for the latest version (--all-but-latest --runtime).
You may also use the option --all-below <VERSION>[ <VERSION>...] , however we recommend that you consult the official documentation which contains the full options list:
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool?tabs=windows#list-command
Example of Custom Software: