Search code examples
c#windowsasp.net-core.net-core

How to remove a dotnet runtime on Windows?


I've found the command dotnet --list-runtimes and it outputs (abbreviated) for me:

Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

I want to remove specific AspNetCore.App runtimes to see if it helps me solve another, different issue - but I don't know how.

I've tried:

  • Using Add/Remove Programs, but it only lists ".NET Core SDK" entries, not runtimes (also: this list is missing several versions that were in the dotnet --list-runtimes output)
  • Going through the available dotnet help entries, but saw no relevant option
  • Go through the remove-runtime-sdk-version readme but it tells me to use Add/Remove Programs, which doesn't help me

I've considered removing the folders mentioned in my output, but am hesitant to just start deleting folders in Program Files subfolders.

Is there a dotnet command or other good way to remove runtimes, specifically AspNetCore versions, so that I can be 100% sure that the "Version Selection" feature from ASP.NET Core cannot pick up a wrong version?


Per the comments, I've tried the dotnet-core-uninstall tool (preview release), but if I run dotnet-core-uninstall it lists zero runtimes it could uninstall, only SDKs (and only 2.x versions at that).


Solution

  • There now is a officially recommended method to uninstall .net runtime and sdk. The gist of it is:

    • Install the ".NET Uninstall Tool"
    • Use dotnet-core-uninstall with its various commands (list, dry-run, and remove)

    Use with care!