从 .NET Core 2.1 开始,.NET CLI 提供一些可用于列出计算机上安装的 SDK 和运行时版本的选项。 使用 dotnet –list-sdks 查看计算机上安装的 SDK 列表。 使用 dotnet --list-runtimes
查看计算机上安装的运行时列表。 下文显示了 Windows、macOS 或 Linux 的典型输出:
<code class="language-shell" lang="shell">dotnet --list-sdks 1.0.1 [/usr/local/share/dotnet/sdk] 1.0.4 [/usr/local/share/dotnet/sdk] 2.0.0-preview1-005977 [/usr/local/share/dotnet/sdk] 2.0.0-preview2-006497 [/usr/local/share/dotnet/sdk] 2.0.0 [/usr/local/share/dotnet/sdk] 2.1.4 [/usr/local/share/dotnet/sdk] 2.1.300-preview2-008530 [/usr/local/share/dotnet/sdk] 2.1.300 [/usr/local/share/dotnet/sdk] 2.1.301 [/usr/local/share/dotnet/sdk] $ dotnet --list-runtimes Microsoft.AspNetCore.All 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0-preview1-002111-00 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0-preview2-25407-01 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0-preview2-26406-04 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] </code>
在 Mac 上,必须通过删除包含该版本的目录,分别删除 SDK 和运行时。 例如,要删除 1.0.1 SDK 和运行时,可使用以下 bash 命令:
<code class="language-shell" lang="shell">sudo rm -rf /usr/local/share/dotnet/sdk/1.0.1 sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.1 sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/1.0.1 sudo rm -rf /usr/local/share/dotnet/host/fxr/1.0.1 </code>
SDK 和运行时的父目录列在 dotnet --list-sdks
和 dotnet --list-runtimes
命令的输出中,如上表所示。