0

I am getting the following errors on NSwag Studio since a week. I had done a VS 2022 update recently and the current version is 17.5.5. I tried reverting to the previous version but it still doesn't help. I get this error while trying to generate clients from NSwag Studio and also while running a project in VS that uses the NSwag build command in the csproj

error : Could not resolve SDK "Microsoft.NET.Sdk.Web". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
error :   The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
error :   MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.NET.Sdk.Web" because directory "C:\Program Files\dotnet\sdk\7.0.202\Microsoft.NET.Sdk.Web\Sdk" did not exist.
C:\Users\<project path> : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

  1. Project type: <Project Sdk="Microsoft.NET.Sdk.Web">
  2. Target framework: <TargetFramework>netcoreapp3.1</TargetFramework>
  3. NSwag commands:<Target Name="NSwag" AfterTargets="Build"> <Exec Command="$(NSwagExe_Core31) run nswag.json /variables:Configuration=$(Configuration)" /> </Target>
codredd
  • 21
  • 3

1 Answers1

0

I have finally resolved this issue. It wasn't happening because of NSawg.

After I had updated my VS 2022, the path variable MSBuildSDKsPath got added with .net 7 SDKs path. I deleted this path variable and deleted it from registry and I no longer get this error.

codredd
  • 21
  • 3