.NET Core 解除安裝工具.NET Core Uninstall Tool

.Net Core 卸載工具dotnet-core-uninstall )可讓您從系統中移除 .net Core sdk 和執行時間。The .NET Core Uninstall Tool (dotnet-core-uninstall) lets you remove .NET Core SDKs and Runtimes from a system. 有一組選項可用來指定您要卸載的版本。A collection of options is available to specify which versions you want to uninstall.

此工具支援 Windows 和 macOS。The tool supports Windows and macOS. 目前不支援 Linux。Linux is currently not supported.

在 Windows 上,此工具只能使用下列其中一個安裝程式來卸載已安裝的 Sdk 和執行時間:On Windows, the tool can only uninstall SDKs and Runtimes that were installed using one of the following installers:

  • .NET Core SDK 和執行時間安裝程式。The .NET Core SDK and runtime installer.
  • Visual Studio 安裝程式的版本早于 Visual Studio 2019 16.3 版。The Visual Studio installer in versions earlier than Visual Studio 2019 version 16.3.

在 macOS 上,此工具只能卸載位於 /usr/local/share/dotnet資料夾中的 sdk 和執行時間。On macOS, the tool can only uninstall SDKs and runtimes located in the /usr/local/share/dotnet folder.

基於這些限制,此工具可能無法卸載您電腦上的所有 .NET Core Sdk 和執行時間。Because of these limitations, the tool may not be able to uninstall all of the .NET Core SDKs and runtimes on your machine. 您可以使用 dotnet --info 命令來尋找已安裝的所有 .Net Core sdk 和執行時間,包括此工具無法移除的 sdk 和執行時間。You can use the dotnet --info command to find all of the .NET Core SDKs and runtimes installed, including those SDKs and runtimes that this tool can't remove. dotnet-core-uninstall list命令會顯示哪些 sdk 可以使用工具卸載。The dotnet-core-uninstall list command displays which SDKs can be uninstalled with the tool.

安裝工具Install the tool

您可以從工具的 [版本] 頁面下載 .Net Core 卸載工具,並在dotnet/cli-實驗室GitHub 存放庫中尋找原始程式碼。You can download the .NET Core Uninstall Tool from the tool's releases page and find the source code at the dotnet/cli-lab GitHub repository.

注意

此工具需要提高許可權,才能卸載 .NET Core Sdk 和執行時間。The tool requires elevation to uninstall .NET Core SDKs and runtimes. 因此,它應該安裝在受寫入保護的目錄中,例如 Windows 上的C:\Program檔案或 macOS 上的 /usr/local/binTherefore, it should be installed in a write-protected directory such as C:\Program Files on Windows or /usr/local/bin on macOS. 另請參閱dotnet 命令的更高存取權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:

步驟 1-顯示已安裝的 .NET Core Sdk 和執行時間Step 1 - Display installed .NET Core SDKs and runtimes

dotnet-core-uninstall list 命令會列出已安裝的 .Net Core sdk 和可使用此工具移除的執行時間。The dotnet-core-uninstall list command lists the installed .NET Core SDKs and runtimes that can be removed with this tool. Visual Studio 可能需要一些 Sdk 和執行時間,而且會顯示不建議將它們卸載的原因。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.

注意

dotnet-core-uninstall list在大部分情況下,命令的輸出不會符合輸出中已安裝的版本清單 dotnet --infoThe 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. 具體而言,此工具不會顯示 zip 檔案所安裝或受 Visual Studio 管理的版本(任何以 Visual Studio 2019 16.3 或更新版本安裝的版本)。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). 檢查版本是否由 Visual Studio 管理的其中一種方式是在中加以查看 Add or Remove Programs ,其中 Visual Studio 的受控版本會在其顯示名稱中標示為。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-核心-卸載清單dotnet-core-uninstall list

概要Synopsis

dotnet-core-uninstall list [options]

選項Options

  • --aspnet-runtime

    列出所有可使用此工具卸載的 ASP.NET Core 執行時間。Lists all the ASP.NET Core runtimes that can be uninstalled with this tool.

  • --hosting-bundle

    列出所有可使用此工具卸載的 .NET Core 裝載套件組合。Lists all the .NET Core hosting bundles that can be uninstalled with this tool.

  • --runtime

    列出所有可使用此工具卸載的 .NET Core 執行時間。Lists all .NET Core runtimes that can be uninstalled with this tool.

  • --sdk

    列出所有可使用此工具卸載的 .NET Core Sdk。Lists all .NET Core SDKs that can be uninstalled with this tool.

  • -v, --verbosity <LEVEL>

    設定詳細資訊層級。Sets the verbosity level. 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. 預設值為 normalThe default value is normal.

  • --x64

    列出所有可使用此工具卸載的 x64 .NET Core Sdk 和執行時間。Lists all x64 .NET Core SDKs and runtimes that can be uninstalled with this tool.

  • --x86

    列出所有可使用此工具卸載的 x86 .NET Core Sdk 和執行時間。Lists all x86 .NET Core SDKs and runtimes that can be uninstalled with this tool.

範例Examples

  • 列出所有可使用此工具移除的 .NET Core Sdk 和執行時間:List all .NET Core SDKs and runtimes that can be removed with this tool:

    dotnet-core-uninstall list
    
  • 列出所有 x64 .NET Core Sdk 和執行時間:List all x64 .NET Core SDKs and runtimes:

    dotnet-core-uninstall list --x64
    
  • 列出所有的 x86 .NET Core Sdk:List all x86 .NET Core SDKs:

    dotnet-core-uninstall list --sdk --x86
    

步驟 2-進行試執行Step 2 - Do a dry run

dotnet-core-uninstall dry-rundotnet-core-uninstall whatif 命令會顯示 .Net Core sdk 和執行時間,將會根據所提供的選項而移除,而不需執行卸載。The dotnet-core-uninstall dry-run and dotnet-core-uninstall whatif commands display the .NET Core SDKs and runtimes that will be removed based on the options provided without performing the uninstall. 這些命令是同義字。These commands are synonyms.

dotnet-核心-卸載試執行和 dotnet-核心-卸載 whatifdotnet-core-uninstall dry-run and dotnet-core-uninstall whatif

概要Synopsis

dotnet-core-uninstall dry-run [options] [<VERSION>...]

dotnet-core-uninstall whatif [options] [<VERSION>...]

引數Arguments

  • VERSION

    要卸載的指定版本。The specified version to uninstall. 您可以逐一列出數個版本,並以空格分隔。You may list several versions one after the other, separated by spaces. 也支援回應檔案。Response files are also supported.

    提示

    回應檔案是將所有版本放在命令列上的替代方案。Response files are an alternative to placing all the versions on the command line. 它們是文字檔,通常 * 副檔名為 .rsp,而每個版本都會列在個別的一行上。They're text files, typically with a *.rsp extension, and each version is listed on a separate line. 若要指定引數的回應檔 VERSION ,請使用 @ 緊接在回應檔名稱後面的字元。To specify a response file for the VERSION argument, use the @ character immediately followed by the response file name.

選項Options

  • --all

    移除所有 .NET Core Sdk 和執行時間。Removes all .NET Core SDKs and runtimes.

  • --all-below <VERSION>[ <VERSION>...]

    只移除版本小於指定版本的 .NET Core Sdk 和執行時間。Removes only the .NET Core SDKs and runtimes with a version smaller than the specified version. 指定的版本仍會安裝。The specified version remains installed.

  • --all-but <VERSIONS>[ <VERSION>...]

    除了指定的版本之外,移除所有 .NET Core Sdk 和執行時間。Removes all .NET Core SDKs and runtimes, except those versions specified.

  • --all-but-latest

    移除 .NET Core Sdk 和執行時間,但不含最高版本。Removes .NET Core SDKs and runtimes, except the one highest version.

  • --all-lower-patches

    移除由較高修補程式取代的 .NET Core Sdk 和執行時間。Removes .NET Core SDKs and runtimes superseded by higher patches. 此選項可保護 global. json。This option protects global.json.

  • --all-previews

    移除標示為預覽的 .NET Core Sdk 和執行時間。Removes .NET Core SDKs and runtimes marked as previews.

  • --all-previews-but-latest

    移除標記為預覽的 .NET Core Sdk 和執行時間,但最高預覽版本除外。Removes .NET Core SDKs and runtimes marked as previews except the one highest preview.

  • --aspnet-runtime

    只移除 ASP.NET Core 執行時間。Removes ASP.NET Core runtimes only.

  • --hosting-bundle

    只會移除 .NET Core 執行時間和裝載套件組合。Removes .NET Core runtime and hosting bundles only.

  • --major-minor <MAJOR_MINOR>

    移除符合指定版本的 .NET Core Sdk 和執行時間 major.minorRemoves .NET Core SDKs and runtimes that match the specified major.minor version.

  • --runtime

    只會移除 .NET Core 執行時間。Removes .NET Core runtimes only.

  • --sdk

    僅移除 .NET Core Sdk。Removes .NET Core SDKs only.

  • -v, --verbosity <LEVEL>

    設定詳細資訊層級。Sets the verbosity level. 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. 預設值為 normalThe default value is normal.

  • --x64

    必須搭配 --sdk 、和使用, --runtime --aspnet-runtime 才能移除 x64 sdk 或執行時間。Must be used with --sdk, --runtime, and --aspnet-runtime to remove x64 SDKs or runtimes.

  • --x86

    必須搭配 --sdk 、和使用, --runtime --aspnet-runtime 才能移除 x86 sdk 或執行時間。Must be used with --sdk, --runtime, and --aspnet-runtime to remove x86 SDKs or runtimes.

  • --force 強制移除 Visual Studio 可能使用的版本。--force Forces removal of versions that might be used by Visual Studio.

注意:Notes:

  1. --sdk --runtime 需要、、 --aspnet-runtime--hosting-bundle 其中一個。Exactly one of --sdk, --runtime, --aspnet-runtime, and --hosting-bundle is required.
  2. --all--all-below--all-but--all-but-latest--all-lower-patches 、、、 --all-previews --all-previews-but-latest --major-minor[<VERSION>...] 是獨佔的。--all, --all-below, --all-but, --all-but-latest, --all-lower-patches, --all-previews, --all-previews-but-latest, --major-minor, and [<VERSION>...] are exclusive.
  3. 如果 --x64 --x86 未指定或,則會移除 x64 和 x86。If --x64 or --x86 aren't specified, then both x64 and x86 will be removed.

範例Examples

注意

根據預設,Visual Studio 或其他 Sdk 可能需要的 .NET Core Sdk 和執行時間不會包含在 dotnet-core-uninstall dry-run 輸出中。By default, .NET Core SDKs and runtimes that may be required by Visual Studio or other SDKs are not included in dotnet-core-uninstall dry-run output. 在下列範例中,某些指定的 Sdk 和執行時間可能不會包含在輸出中,視電腦的狀態而定。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. 若要包含所有 Sdk 和執行時間,請將它們明確列出為引數或使用 --force 選項。To include all SDKs and runtimes, list them explicitly as arguments or use the --force option.

  • 試執行移除所有已被較高修補程式取代的 .NET Core 執行時間:Dry run of removing all .NET Core runtimes that have been superseded by higher patches:

    dotnet-core-uninstall dry-run --all-lower-patches --runtime
    
  • 在版本下方移除所有 .NET Core Sdk 的試執行 2.2.301Dry run of removing all .NET Core SDKs below the version 2.2.301:

    dotnet-core-uninstall whatif --all-below 2.2.301 --sdk
    

步驟 3-卸載 .NET Core Sdk 和執行時間Step 3 - Uninstall .NET Core SDKs and Runtimes

dotnet-core-uninstall remove卸載選項組合所指定的 .NET Core Sdk 和執行時間。dotnet-core-uninstall remove uninstalls .NET Core SDKs and Runtimes that are specified by a collection of options. 此工具無法用來卸載版本5.0 或更高版本的 Sdk 和執行時間。The tool can't be used to uninstall SDKs and Runtimes with version 5.0 or above.

由於此工具具有破壞性的行為,因此強烈建議您在執行 [移除] 命令之前先進行試執行。Since this tool has a destructive behavior, it's highly recommended that you do a dry run before running the remove command. 試執行會顯示當您使用命令時,將會移除哪些 .NET Core Sdk 和執行時間 removeThe dry run will show you what .NET Core SDKs and runtimes will be removed when you use the remove command. 請參閱我應該移除版本嗎?以瞭解哪些 sdk 和執行時間可以安全地移除。Refer to Should I remove a version? to learn which SDKs and runtimes are safe to remove.

警告

請記住下列注意事項:Keep in mind the following caveats:

  • 這項工具可以卸載電腦上的檔案所需的 .NET Core SDK 版本 global.jsonThis tool can uninstall versions of the .NET Core SDK that are required by global.json files on your machine. 您可以從下載 .Net core頁面重新安裝 .Net core sdk。You can reinstall .NET Core SDKs from the Download .NET Core page.
  • 這項工具可以卸載電腦上架構相依應用程式所需的 .NET Core 執行階段版本。This tool can uninstall versions of the .NET Core runtime that are required by framework dependent applications on your machine. 您可以從 [下載 .Net core ] 頁面重新安裝 .net core 執行時間。You can reinstall .NET Core runtimes from the Download .NET Core page.
  • 這項工具可以卸載 Visual Studio 依賴之 .NET Core SDK 和執行時間的版本。This tool can uninstall versions of the .NET Core SDK and runtime that Visual Studio relies on. 如果您中斷 Visual Studio 安裝,請在 Visual Studio 安裝程式中執行 [修復],以回到作用中狀態。If you break your Visual Studio installation, run "Repair" in the Visual Studio installer to get back to a working state.

根據預設,所有命令都會保留 Visual Studio 或其他 Sdk 可能需要的 .NET Core Sdk 和執行時間。By default, all commands keep the .NET Core SDKs and runtimes that may be required by Visual Studio or other SDKs. 這些 Sdk 和執行時間可以藉由將它們明確地列為引數或使用選項來進行卸載 --forceThese SDKs and runtimes can be uninstalled by listing them explicitly as arguments or by using the --force option.

此工具需要提高許可權,才能卸載 .NET Core Sdk 和執行時間。The tool requires elevation to uninstall .NET Core SDKs and runtimes. 在 Windows 上的系統管理員命令提示字元中,以及 sudo 在 macOS 上執行工具。Run the tool in an Administrator command prompt on Windows and with sudo on macOS. dry-runwhatif 命令不需要提高許可權。The dry-run and whatif commands don't require elevation.

dotnet-核心-卸載移除dotnet-core-uninstall remove

概要Synopsis

dotnet-core-uninstall remove [options] [<VERSION>...]

引數Arguments

  • VERSION

    要卸載的指定版本。The specified version to uninstall. 您可以逐一列出數個版本,並以空格分隔。You may list several versions one after the other, separated by spaces. 也支援回應檔案。Response files are also supported.

    提示

    回應檔案是將所有版本放在命令列上的替代方案。Response files are an alternative to placing all the versions on the command line. 它們是文字檔,通常 * 副檔名為 .rsp,而每個版本都會列在個別的一行上。They're text files, typically with a *.rsp extension, and each version is listed on a separate line. 若要指定引數的回應檔 VERSION ,請使用 @ 緊接在回應檔名稱後面的字元。To specify a response file for the VERSION argument, use the @ character immediately followed by the response file name.

選項Options

  • --all

    移除所有 .NET Core Sdk 和執行時間。Removes all .NET Core SDKs and runtimes.

  • --all-below <VERSION>[ <VERSION>...]

    只移除版本小於指定版本的 .NET Core Sdk 和執行時間。Removes only the .NET Core SDKs and runtimes with a version smaller than the specified version. 指定的版本仍會安裝。The specified version remains installed.

  • --all-but <VERSIONS>[ <VERSION>...]

    除了指定的版本之外,移除所有 .NET Core Sdk 和執行時間。Removes all .NET Core SDKs and runtimes, except those versions specified.

  • --all-but-latest

    移除 .NET Core Sdk 和執行時間,但不含最高版本。Removes .NET Core SDKs and runtimes, except the one highest version.

  • --all-lower-patches

    移除由較高修補程式取代的 .NET Core Sdk 和執行時間。Removes .NET Core SDKs and runtimes superseded by higher patches. 此選項可保護 global. json。This option protects global.json.

  • --all-previews

    移除標示為預覽的 .NET Core Sdk 和執行時間。Removes .NET Core SDKs and runtimes marked as previews.

  • --all-previews-but-latest

    移除標記為預覽的 .NET Core Sdk 和執行時間,但最高預覽版本除外。Removes .NET Core SDKs and runtimes marked as previews except the one highest preview.

  • --aspnet-runtime

    只移除 ASP.NET Core 執行時間。Removes ASP.NET Core runtimes only.

  • --hosting-bundle

    只會移除 .NET Core 裝載套件組合。Removes .NET Core hosting bundles only.

  • --major-minor <MAJOR_MINOR>

    移除符合指定版本的 .NET Core Sdk 和執行時間 major.minorRemoves .NET Core SDKs and runtimes that match the specified major.minor version.

  • --runtime

    只會移除 .NET Core 執行時間。Removes .NET Core runtimes only.

  • --sdk

    僅移除 .NET Core Sdk。Removes .NET Core SDKs only.

  • -v, --verbosity <LEVEL>

    設定詳細資訊層級。Sets the verbosity level. 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. 預設值為 normalThe default value is normal.

  • --x64

    必須搭配 --sdk 、和使用, --runtime --aspnet-runtime 才能移除 x64 sdk 或執行時間。Must be used with --sdk, --runtime, and --aspnet-runtime to remove x64 SDKs or runtimes.

  • --x86

    必須搭配 --sdk 、和使用, --runtime --aspnet-runtime 才能移除 x86 sdk 或執行時間。Must be used with --sdk, --runtime, and --aspnet-runtime to remove x86 SDKs or runtimes.

  • -y, --yes 執行命令,而不需要有 [是] 或 [否] 確認。-y, --yes Executes the command without requiring a yes or no confirmation.

  • --force 強制移除 Visual Studio 可能使用的版本。--force Forces removal of versions that might be used by Visual Studio.

注意:Notes:

  1. --sdk --runtime 需要、、 --aspnet-runtime--hosting-bundle 其中一個。Exactly one of --sdk, --runtime, --aspnet-runtime, and --hosting-bundle is required.
  2. --all--all-below--all-but--all-but-latest--all-lower-patches 、、、 --all-previews --all-previews-but-latest --major-minor[<VERSION>...] 是獨佔的。--all, --all-below, --all-but, --all-but-latest, --all-lower-patches, --all-previews, --all-previews-but-latest, --major-minor, and [<VERSION>...] are exclusive.
  3. 如果 --x64 --x86 未指定或,則會移除 x64 和 x86。If --x64 or --x86 aren't specified, then both x64 and x86 will be removed.

範例Examples

注意

根據預設,Visual Studio 或其他 Sdk 可能需要的 .NET Core Sdk 和執行時間會保留下來。By default, .NET Core SDKs and runtimes that may be required by Visual Studio or other SDKs are kept. 在下列範例中,某些指定的 Sdk 和執行時間可能會保留,視電腦的狀態而定。In the following examples, some of the specified SDKs and runtimes may remain, depending on the state of the machine. 若要移除所有 Sdk 和執行時間,請將它們明確列出為引數或使用 --force 選項。To remove all SDKs and runtimes, list them explicitly as arguments or use the --force option.

  • 移除版本除外的所有 .NET Core 執行時間, 3.0.0-preview6-27804-01 而不需要進行 Y/N 確認:Remove all .NET Core runtimes except the version 3.0.0-preview6-27804-01 without requiring Y/N confirmation:

    dotnet-core-uninstall remove --all-but 3.0.0-preview6-27804-01 --runtime --yes
    
  • 移除所有 .NET Core 1.1 Sdk,而不需要進行 Y/n 確認:Remove all .NET Core 1.1 SDKs without requiring Y/n confirmation:

    dotnet-core-uninstall remove --sdk --major-minor 1.1 -y
    
  • 移除沒有主控台輸出的 .NET Core 1.1.11 SDK:Remove the .NET Core 1.1.11 SDK with no console output:

    dotnet-core-uninstall remove 1.1.11 --sdk --yes --verbosity q
    
  • 移除此工具可安全移除的所有 .NET Core Sdk:Remove all .NET Core SDKs that can safely be removed by this tool:

    dotnet-core-uninstall remove --all --sdk
    
  • 移除此工具可移除的所有 .NET Core Sdk,包括 Visual Studio 可能需要的 Sdk (不建議):Remove all .NET Core 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 --force
    
  • 移除回應檔中指定的所有 .NET Core Sdkversions.rspRemove all .NET Core SDKs that are specified in the response file versions.rsp

    dotnet-core-uninstall remove --sdk @versions.rsp
    

    版本 .rsp的內容如下所示:The content of versions.rsp is as follows:

    2.2.300
    2.1.700
    

步驟 4-刪除 NuGet fallback 資料夾(選擇性)Step 4 - Delete the NuGet fallback folder (optional)

在某些情況下,您不再需要, NuGetFallbackFolder 而且可能想要將它刪除。In some cases, you no longer need the NuGetFallbackFolder and may wish to delete it. 如需刪除此資料夾的詳細資訊,請參閱移除 NuGetFallbackFolderFor more information about deleting this folder, see Remove the NuGetFallbackFolder.

卸載工具Uninstall the tool

  1. 開啟 [新增或移除程式]****。Open Add or Remove Programs.
  2. 搜尋 Microsoft .NET Core SDK Uninstall ToolSearch for Microsoft .NET Core SDK Uninstall Tool.
  3. 選取 [解除安裝]。Select Uninstall.