.net-core - VS 2022 升级后 dotnet build 停止工作
问题描述
我将 Visual Studio Community 升级到最终版本,但它停止工作。具体来说,我可以生成一个新项目,但是当我尝试加载它时,它给了我一个错误
关键项目“SdkTest”加载失败| [MSB4236] 找不到指定的 SDK“Microsoft.NET.Sdk.Web”。...\SdkTest.csproj
即使构建和运行工作正常
我在 VS2022 上运行了“修复”,它现在似乎可以从 Visual Studio工作。但是,dotnet --info
不显示任何SDK;只有运行时;和dotnet build
或dotnet new
给出一个错误:
C:\Code>dotnet new console -o myapp
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
* You intended to execute a .NET program:
The application 'new' does not exist.
* You intended to execute a .NET SDK command:
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
https://aka.ms/dotnet-download
我什至重新安装了 .NET 6,并在应用程序列表中看到了它(以及较旧的 SDK)。我检查了路径,我看到了我希望看到的一切:
C:\Program Files (x86)\dotnet\
C:\Program Files\dotnet\
C:\Users\me\.dotnet\tools
我正在运行 Windows 11。
解决方案
这是 VS2022 安装中的已知错误。
问题是dotnet
您访问位于内部Program Files(x86)/dotnet
,但所有 sdk 都位于Program Files/dotnet
. 你只需要编辑PATH
环境变量就Program Files/dotnet
可以了Program Files(x86)/dotnet
。如果您没有Program Files(x86)/dotnet
在用户环境变量中看到(这很可能发生),则编辑系统环境变量(位于下方)
推荐阅读
- excel - 选定范围另存为 PDF
- count - 总和,元素的平均值并计算Prolog中列表中元素的出现次数
- javascript - 如何防止 Element.focus() 在 contenteditable div 中更改光标位置?
- tsql - 每个帐号的运行余额
- java - Gradle IntelliJ Idea JavaFX 运行时错误
- node.js - 如何将数据从 promptContext 传递到 Luis 结果?
- api - 我应该如何处理过期的 JWT
- javascript - 如何在 Charts.JS 中为单个值在折线图中绘制一条线
- python - 可调整 lambda 到不同的列表
- php - 无法使用带有 Laravel 的 LibreOffice 将 word doc 转换为 pdf