查看 Windows 上装了哪些 .NET SDK 和运行时
两条 dotnet 命令列出所有已安装的 .NET SDK 和运行时版本及路径,排查版本问题第一步。
运行 `dotnet --list-sdks` 查看 SDK,运行 `dotnet --list-runtimes` 查看运行时。
01命令
命令
$ dotnet --list-sdks; dotnet --list-runtimes02作用说明
当项目提示缺少某个 .NET 版本或编译用了错误的版本时,第一步就是确认机器上实际装了什么。`dotnet --list-sdks` 会列出每个 SDK 版本及其安装路径,`dotnet --list-runtimes` 则列出运行时(ASP.NET Core、桌面等)——机器上往往并存多个版本。这两条都是 dotnet CLI 自带的只读查询,瞬间出结果。
03风险
!注意: 结果反映的是 PATH 中排在最前面的那个 dotnet;如果你装了多套 .NET,先确认 PATH 指向的是你期望的那一个。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- dotnet command reference | Microsoft Learn依据: Documents dotnet --list-sdks and --list-runtimes options that print installed SDK and runtime versions with their paths.
最后验证: 2026-09-18 · 分类: 开发者