VS 2022 升级后 dotnet build 停止工作

Fel*_*lix 3 msbuild .net-core visual-studio-2022

我将 Visual Studio Community 升级到最终版本,但它停止工作。具体来说,我可以生成一个新项目,但是当我尝试加载它时,它给了我一个错误

关键项目“SdkTest”加载失败| [MSB4236] 找不到指定的 SDK“Microsoft.NET.Sdk.Web”。...\SdkTest.csproj

尽管构建和运行工作正常

我在 VS2022 上运行了“修复”,它现在似乎可以在 Visual Studio . 但是,dotnet --info不显示任何SDK;仅运行时;和/dotnet builddotnet 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
Run Code Online (Sandbox Code Playgroud)

我什至重新安装了 .NET 6,并在应用程序列表中看到它(以及旧版 SDK)。我检查了路径,我看到了我期望看到的一切:

C:\Program Files (x86)\dotnet\
C:\Program Files\dotnet\
C:\Users\me\.dotnet\tools
Run Code Online (Sandbox Code Playgroud)

我运行的是 Windows 11。

JL0*_*0PD 7

这是VS2022 安装中的已知错误。

问题是dotnet您访问位于内部Program Files(x86)/dotnet,但所有sdk都位于Program Files/dotnet. 您只需要编辑PATH环境变量Program Files/dotnet即可Program Files(x86)/dotnet。如果你没有看到Program Files(x86)/dotnet(这很可能发生),则编辑系统环境变量(位于下面)

屏幕截图示例:/sf/answers/3099069221/