Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet build stopped working after VS 2022 upgrade

I upgraded Visual Studio Community to the final release, and it stopped working. Specifically, I could generate a new project, but when I try to load it, it gave me an error

Critical Project 'SdkTest' load failed| [MSB4236] The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. ...\SdkTest.csproj

Even though build and run worked fine

I ran "repair" on VS2022, and it seems to be working now from Visual Studio. However, dotnet --info doesn't show any SDKs; only runtime; and dotnet build or dotnet new give an error:

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

I even reinstalled .NET 6 and I see it in the list of applications (along with older SDKs). I checked the path, and I see everything that I expect to see:

C:\Program Files (x86)\dotnet\
C:\Program Files\dotnet\
C:\Users\me\.dotnet\tools

I am running Windows 11.

like image 995
Felix Avatar asked Nov 19 '25 04:11

Felix


1 Answers

It's known bug in VS2022 installation.

Problem is that dotnet you access is located inside Program Files(x86)/dotnet, but all sdk's are located in Program Files/dotnet. You simply need to edit PATH environment variable so Program Files/dotnet goes before Program Files(x86)/dotnet. If you don't see Program Files(x86)/dotnet in user environment variable (which is likely to happen) then edit system environment variable (located below)

Example with screenshots: https://stackoverflow.com/a/44272417/10339675

like image 50
JL0PD Avatar answered Nov 21 '25 09:11

JL0PD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!