.NET uninstall tool
The .NET uninstall tool (dotnet-core-uninstall) lets you remove .NET SDKs and runtimes from a system. A collection of options is available to specify which versions you want to uninstall.
The tool supports Windows and macOS. Linux is currently not supported.
On Windows, the tool can only uninstall SDKs and runtimes that were installed using one of the following installers:
- The .NET SDK and runtime installer.
- The Visual Studio installer in versions earlier than Visual Studio 2019 version 16.3.
On macOS, the tool can only uninstall SDKs and runtimes located in the /usr/local/share/dotnet folder.
Because of these limitations, the tool might not be able to uninstall all of the .NET SDKs and runtimes on your machine. You can use the dotnet --info command to find all of the .NET SDKs and runtimes installed, including those SDKs and runtimes that the tool can't remove. The dotnet-core-uninstall list command displays which SDKs can be uninstalled with the tool.
Note
Currently, the .NET Uninstall Tool doesn't support .NET 8+. For more information about the release schedule of the tool, see GitHub - dotnet-uninstall-tool Roadmap.
Install the tool
You can download .NET uninstall tool from the tool's releases page and find the source code at the dotnet/cli-lab GitHub repository.
Note
The tool requires elevation to uninstall .NET SDKs and runtimes. Therefore, it should be installed in a write-protected directory such as C:\Program Files on Windows or /usr/local/bin on macOS. For more information, see the Elevated access for dotnet commands and the detailed installation instructions.
Run the tool
The following steps show the recommended approach for running the uninstall tool:
- Step 1 - Display installed .NET SDKs and runtimes
- Step 2 - Do a dry run
- Step 3 - Uninstall .NET SDKs and runtimes
- Step 4 - Delete the NuGet fallback folder (optional)
Step 1 - Display installed .NET SDKs and runtimes
The dotnet-core-uninstall list command lists the installed .NET SDKs and runtimes that can be removed with this tool. Some SDKs and runtimes might be required by Visual Studio and they're displayed with a note of why it isn't recommended to uninstall them.
Note
The output of the dotnet-core-uninstall list command won't match the list of installed versions in the output of dotnet --info in most cases. Specifically, this tool won't display versions installed by zip files or managed by Visual Studio (any version installed with Visual Studio 2019 version 16.3 or later). One way to check if a version is managed by Visual Studio is to view it in Add or Remove Programs, where Visual Studio managed versions are marked as such in their display names.
For more information, see list command later in this article.
Step 2 - Do a dry run
The dotnet-core-uninstall dry-run and dotnet-core-uninstall whatif commands display the .NET SDKs and runtimes that will be removed based on the options provided without performing the uninstall. These commands are synonyms.
For more information, see dry-run and whatif commands later in this article.
Step 3 - Uninstall .NET SDKs and Runtimes
dotnet-core-uninstall remove uninstalls .NET SDKs and Runtimes that are specified by a collection of options.
Since this tool has a destructive behavior, it's highly recommended that you do a dry run before running the remove command. The dry run will show you what .NET SDKs and runtimes will be removed when you use the remove command. Refer to Should I remove a version? to learn which SDKs and runtimes are safe to remove.
Caution
Keep in mind the following caveats:
- This tool can uninstall versions of the .NET SDK that are required by
global.jsonfiles on your machine. You can reinstall .NET SDKs from the Download .NET page. - This tool can uninstall versions of the .NET Runtime that are required by framework dependent applications on your machine. You can reinstall .NET Runtimes from the Download .NET page.
- This tool can uninstall versions of the .NET SDK and runtime that Visual Studio relies on. If you break your Visual Studio installation, run "Repair" in the Visual Studio installer to get back to a working state.
By default, all commands keep the .NET SDKs and runtimes that may be required by Visual Studio or other SDKs. These SDKs and runtimes can be uninstalled by listing them explicitly as arguments or by using the --force option.
The tool requires elevation to uninstall .NET SDKs and runtimes. Run the tool in an Administrator command prompt on Windows and with sudo on macOS. The dry-run and whatif commands don't require elevation.
For more information, see remove command later in this article.
Step 4 - Delete the NuGet fallback folder (optional)
In some cases, you no longer need the NuGetFallbackFolder and may wish to delete it. For more information, see Remove the NuGetFallbackFolder.
Uninstall the tool
- Open Add or Remove Programs.
- Search for
Microsoft .NET SDK Uninstall Tool. - Select Uninstall.
list command
Synopsis
dotnet-core-uninstall list [options]
Options
--aspnet-runtimeLists all the ASP.NET runtimes that can be uninstalled with this tool.
--hosting-bundleLists all the .NET hosting bundles that can be uninstalled with this tool.
--runtimeLists all the .NET runtimes that can be uninstalled with this tool.
--sdkLists all the .NET SDKs that can be uninstalled with this tool.
-v, --verbosity <LEVEL>Sets the verbosity level. Allowed values are
q[uiet],m[inimal],n[ormal],d[etailed], anddiag[nostic]. The default value isnormal.--x64Lists all the x64 .NET SDKs and runtimes that can be uninstalled with this tool.
--x86Lists all the x86 .NET SDKs and runtimes that can be uninstalled with this tool.
Examples
List all the .NET SDKs and runtimes that can be removed with this tool:
dotnet-core-uninstall listList all the x64 .NET SDKs and runtimes:
dotnet-core-uninstall list --x64List all the x86 .NET SDKs:
dotnet-core-uninstall list --sdk --x86
dry-run and whatif commands
Synopsis
dotnet-core-uninstall dry-run [options] [<VERSION>...]
dotnet-core-uninstall whatif [options] [<VERSION>...]
Arguments
VERSION
The specified version to uninstall. You can list several versions one after the other, separated by spaces. Response files are also supported.
Tip
Response files are an alternative to placing all the versions on the command line. They're text files, typically with a *.rsp extension, and each version is listed on a separate line. To specify a response file for the VERSION argument, use the @ character immediately followed by the response file name.
Options
--allRemoves all the .NET SDKs and runtimes.
--all-below <VERSION>[ <VERSION>...]Removes only the .NET SDKs and runtimes with a version smaller than the specified version. The specified version remains installed.
--all-but <VERSIONS>[ <VERSION>...]Removes all the .NET SDKs and runtimes, except those versions specified.
--all-but-latestRemoves the .NET SDKs and runtimes, except the highest version.
--all-lower-patchesRemoves the .NET SDKs and runtimes superseded by higher patches. This option protects global.json file.
--all-previewsRemoves the .NET SDKs and runtimes marked as previews.
--all-previews-but-latestRemoves the .NET SDKs and runtimes marked as previews except the highest preview.
--aspnet-runtimeRemoves the ASP.NET runtimes only.
--hosting-bundleRemoves the .NET runtime and hosting bundles only.
--major-minor <MAJOR_MINOR>Removes the .NET SDKs and runtimes that match the specified
major.minorversion.--runtimeRemoves the .NET runtimes only.
--sdkRemoves the .NET SDKs only.
-v, --verbosity <LEVEL>Sets the verbosity level. Allowed values are
q[uiet],m[inimal],n[ormal],d[etailed], anddiag[nostic]. The default value isnormal.--x64Must be used with
--sdk,--runtime, and--aspnet-runtimeto remove x64 SDKs or runtimes.--x86Must be used with
--sdk,--runtime, and--aspnet-runtimeto remove x86 SDKs or runtimes.--forceForces removal of versions that might be used by Visual Studio.
Note
- Exactly one of
--sdk,--runtime,--aspnet-runtime, and--hosting-bundleis required. --all,--all-below,--all-but,--all-but-latest,--all-lower-patches,--all-previews,--all-previews-but-latest,--major-minor, and[<VERSION>...]are exclusive.- If
--x64or--x86aren't specified, then both x64 and x86 will be removed.
Examples
Note
By default, .NET SDKs and runtimes that might be required by Visual Studio or other SDKs aren't included in the dotnet-core-uninstall dry-run output. In the following examples, depending on the state of the machine, some of the specified SDKs and runtimes might not be included in the output. To include all the SDKs and runtimes, list them explicitly as arguments or use the --force option.
Dry run of removing all the .NET runtimes that have been superseded by higher patches:
dotnet-core-uninstall dry-run --all-lower-patches --runtimeDry run of removing all the .NET SDKs below the version
2.2.301:dotnet-core-uninstall whatif --all-below 2.2.301 --sdk
remove command
Synopsis
dotnet-core-uninstall remove [options] [<VERSION>...]
Arguments
VERSION
The specified version to uninstall. You might list several versions one after the other, separated by spaces. Response files are also supported.
Tip
Response files are an alternative to placing all the versions on the command line. They're text files, typically with a *.rsp extension, and each version is listed on a separate line. To specify a response file for the VERSION argument, use the @ character immediately followed by the response file name.
Options
--allRemoves all the .NET SDKs and runtimes.
--all-below <VERSION>[ <VERSION>...]Removes only the .NET SDKs and runtimes with a version smaller than the specified version. The specified version remains installed.
--all-but <VERSIONS>[ <VERSION>...]Removes all the .NET SDKs and runtimes, except those versions specified.
--all-but-latestRemoves the .NET SDKs and runtimes, except the highest version.
--all-lower-patchesRemoves the .NET SDKs and runtimes superseded by higher patches. This option protects global.json file.
--all-previewsRemoves the .NET SDKs and runtimes marked as previews.
--all-previews-but-latestRemoves the .NET SDKs and runtimes marked as previews except the highest preview.
--aspnet-runtimeRemoves the ASP.NET runtimes only.
--hosting-bundleRemoves the .NET hosting bundles only.
--major-minor <MAJOR_MINOR>Removes the .NET SDKs and runtimes that match the specified
major.minorversion.--runtimeRemoves the .NET runtimes only.
--sdkRemoves the .NET SDKs only.
-v, --verbosity <LEVEL>Sets the verbosity level. Allowed values are
q[uiet],m[inimal],n[ormal],d[etailed], anddiag[nostic]. The default value isnormal.--x64Must be used with
--sdk,--runtime, and--aspnet-runtimeto remove x64 SDKs or runtimes.--x86Must be used with
--sdk,--runtime, and--aspnet-runtimeto remove x86 SDKs or runtimes.-y, --yesExecutes the command without requiring a yes or no confirmation.
--forceForces removal of versions that might be used by Visual Studio.
Note
- Exactly one of
--sdk,--runtime,--aspnet-runtime, and--hosting-bundleis required. --all,--all-below,--all-but,--all-but-latest,--all-lower-patches,--all-previews,--all-previews-but-latest,--major-minor, and[<VERSION>...]are exclusive.- If
--x64or--x86aren't specified, then both x64 and x86 will be removed.
Examples
Note
By default, .NET SDKs and runtimes that might be required by Visual Studio or other SDKs are kept. In the following examples, depending on the state of the machine, some of the specified SDKs and runtimes might remain. To remove all the SDKs and runtimes, list them explicitly as arguments or use the --force option.
Remove all the .NET runtimes except the version
3.0.0-preview6-27804-01without requiring yes or no confirmation:dotnet-core-uninstall remove --all-but 3.0.0-preview6-27804-01 --runtime --yesRemove all the .NET Core 1.1 SDKs without requiring yes or no confirmation:
dotnet-core-uninstall remove --sdk --major-minor 1.1 -yRemove the .NET Core 1.1.11 SDK with no console output:
dotnet-core-uninstall remove 1.1.11 --sdk --yes --verbosity qRemove all the .NET SDKs that can be safely removed by this tool:
dotnet-core-uninstall remove --all --sdkRemove all the .NET SDKs that can be removed by this tool, including those SDKs that might be required by Visual Studio (not recommended):
dotnet-core-uninstall remove --all --sdk --forceRemove all the .NET SDKs that are specified in the versions.rsp response file:
dotnet-core-uninstall remove --sdk @versions.rspThe content of the versions.rsp file is as follows:
2.2.300 2.1.700
Feedback
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.
Submit and view feedback for