.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 may 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 this tool can't remove. The dotnet-core-uninstall list command displays which SDKs can be uninstalled with the tool. Versions 1.2 and later can uninstall SDKs and runtimes with version 5.0 or earlier, and previous versions of the tool can uninstall 3.1 and earlier.
Install the tool
You can download the .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. See also Elevated access for dotnet commands. For more information, see 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 may 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 will not match the list of installed versions in the output of dotnet --info in most cases. Specifically, this tool will not display versions installed by zip files or managed by Visual Studio (any version installed with Visual Studio 2019 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.
dotnet-core-uninstall list
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 .NET Runtimes that can be uninstalled with this tool.
--sdkLists all .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 x64 .NET SDKs and runtimes that can be uninstalled with this tool.
--x86Lists all x86 .NET SDKs and runtimes that can be uninstalled with this tool.
Examples
List all .NET SDKs and runtimes that can be removed with this tool:
dotnet-core-uninstall listList all x64 .NET SDKs and runtimes:
dotnet-core-uninstall list --x64List all x86 .NET SDKs:
dotnet-core-uninstall list --sdk --x86
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.
dotnet-core-uninstall dry-run and dotnet-core-uninstall whatif
Synopsis
dotnet-core-uninstall dry-run [options] [<VERSION>...]
dotnet-core-uninstall whatif [options] [<VERSION>...]
Arguments
VERSIONThe specified version to uninstall. You may 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
VERSIONargument, use the @ character immediately followed by the response file name.
Options
--allRemoves all .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 .NET SDKs and runtimes, except those versions specified.
--all-but-latestRemoves .NET SDKs and runtimes, except the one highest version.
--all-lower-patchesRemoves .NET SDKs and runtimes superseded by higher patches. This option protects global.json.
--all-previewsRemoves .NET SDKs and runtimes marked as previews.
--all-previews-but-latestRemoves .NET SDKs and runtimes marked as previews except the one highest preview.
--aspnet-runtimeRemoves ASP.NET Runtimes only.
--hosting-bundleRemoves .NET Runtime and hosting bundles only.
--major-minor <MAJOR_MINOR>Removes .NET SDKs and runtimes that match the specified
major.minorversion.--runtimeRemoves .NET Runtimes only.
--sdkRemoves .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.
Notes:
- 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 may be required by Visual Studio or other SDKs are not included in dotnet-core-uninstall dry-run output. In the following examples, some of the specified SDKs and runtimes may not be included in the output, depending on the state of the machine. To include all SDKs and runtimes, list them explicitly as arguments or use the --force option.
Dry run of removing all .NET Runtimes that have been superseded by higher patches:
dotnet-core-uninstall dry-run --all-lower-patches --runtimeDry run of removing all .NET SDKs below the version
2.2.301:dotnet-core-uninstall whatif --all-below 2.2.301 --sdk
Step 3 - Uninstall .NET SDKs and Runtimes
dotnet-core-uninstall remove uninstalls .NET SDKs and Runtimes that are specified by a collection of options. Versions 1.2 and later can uninstall SDKs and runtimes with version 5.0 or earlier, and previous versions of the tool can uninstall 3.1 and earlier.
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.
dotnet-core-uninstall remove
Synopsis
dotnet-core-uninstall remove [options] [<VERSION>...]
Arguments
VERSIONThe specified version to uninstall. You may 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
VERSIONargument, use the @ character immediately followed by the response file name.
Options
--allRemoves all .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 .NET SDKs and runtimes, except those versions specified.
--all-but-latestRemoves .NET SDKs and runtimes, except the one highest version.
--all-lower-patchesRemoves .NET SDKs and runtimes superseded by higher patches. This option protects global.json.
--all-previewsRemoves .NET SDKs and runtimes marked as previews.
--all-previews-but-latestRemoves .NET SDKs and runtimes marked as previews except the one highest preview.
--aspnet-runtimeRemoves ASP.NET Runtimes only.
--hosting-bundleRemoves .NET hosting bundles only.
--major-minor <MAJOR_MINOR>Removes .NET SDKs and runtimes that match the specified
major.minorversion.--runtimeRemoves .NET Runtimes only.
--sdkRemoves .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.
Notes:
- 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 may be required by Visual Studio or other SDKs are kept. In the following examples, some of the specified SDKs and runtimes may remain, depending on the state of the machine. To remove all SDKs and runtimes, list them explicitly as arguments or use the --force option.
Remove all .NET Runtimes except the version
3.0.0-preview6-27804-01without requiring Y/N confirmation:dotnet-core-uninstall remove --all-but 3.0.0-preview6-27804-01 --runtime --yesRemove all .NET Core 1.1 SDKs without requiring Y/n 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 .NET SDKs that can safely be removed by this tool:
dotnet-core-uninstall remove --all --sdkRemove all .NET SDKs that can be removed by this tool, including those SDKs that may be required by Visual Studio (not recommended):
dotnet-core-uninstall remove --all --sdk --forceRemove all .NET SDKs that are specified in the response file
versions.rspdotnet-core-uninstall remove --sdk @versions.rspThe content of versions.rsp is as follows:
2.2.300 2.1.700
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 about deleting this folder, see Remove the NuGetFallbackFolder.
Uninstall the tool
Maklum balas
Kirim dan lihat maklum balas untuk