Sdk: Weird error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found

Created on 19 Apr 2019  路  10Comments  路  Source: dotnet/sdk

Cannot get rid of weird error

error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.

When I build the project with CLI dotnet build whatever project I try to build (_all .csproj files refer to Sdk="Microsoft.NET.Sdk" or Sdk="Microsoft.NET.Sdk.Web" and it causes error as I understand_) it fails with error

Though I was able to build and run these projects with Visual Studio 2017.

Had to uninstall all related .Net stuff (all SDKs, .Net runtimes and VS2017 ) then reinstalled VS2019 Community from scratch. The issue is still the same - I am able to build and run the application with VS but can not build or run any of existing proejcts from CLI.
It still fails with mentioned error.

It is not obvious what version of SDK it complains for, I try to install consecutively all SDKs from Microsoft "downloads" page but nothing helped.

Currently
dotnet --list-sdks

produces the output:

2.1.202 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.100-preview2-009404 [C:\Program Files\dotnet\sdk]
2.2.100-preview3-009430 [C:\Program Files\dotnet\sdk]
2.2.100 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
2.2.106 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]

I have checked several related issues here but all of them have been closed and none of them proposes relevant solution.

Most helpful comment

Hi @peterhuene !

I have never set MSBuildSDKsPath manually before I faced the issue, and everything worked fine.

I tried to set MSBuildSDKsPath in terms of fixing SDK issue (some similar issues on Stackoverflow suggested to set this variable in order to fix).

BR
Igor

All 10 comments

Hi @IgorXq. Thank you for reporting this issue to us.

Would you mind pasting the output of dotnet --info from the command line in the failing project's directory?

Is the project referencing Microsoft.NET.Sdk.Web directly or is one of its dependencies?

Hi @peterhuene ! Thank you for quick response.

Sure.

OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.203\

Host (useful for support):
Version: 2.2.4
Commit: f95848e524

.NET Core SDKs installed:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.100-preview2-009404 [C:\Program Files\dotnet\sdk]
2.2.100-preview3-009430 [C:\Program Files\dotnet\sdk]
2.2.100 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
2.2.106 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0-preview2-35157 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0-preview3-35497 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0-preview2-35157 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0-preview3-35497 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0-preview2-26905-02 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0-preview3-27014-02 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

SDK is referenced in .csproj files like that

<Project Sdk="Microsoft.NET.Sdk.Web">

or

<Project Sdk="Microsoft.NET.Sdk">

None of them gets built

Hi @IgorXq. Do you happen to have a MSBuildSDKsPath or DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR environment variable set? You likely don't, but those would override the places where MSBuild and the .NET Core SDK look for SDKs.

Does the directory C:\Program Files\dotnet\sdk\2.2.203\Sdks\Microsoft.NET.Sdk.Web exist?

Hi @peterhuene

Having checked environment variables I have noticed the trailng quote in MSBuildSDKsPath variable.
Removed it and projects starts to compile.

But I have to clarify that I have to set MSBuildSDKsPath manually when ran into the issue, and suggest to improve the error message to be more detailed to get the developer know what version of SDK it complains for and what location it seeks.

I suppose that initially I ran into the issue when I have to remove obsolete SDKs (I had to do it because after migration to 2.2 Visual studio refused to compile - also complained to SDKs and it is still another issue, then I have googled that I can try to remove obsolete SDKs in order to get VS worked, and it helped to regain Visual Studio compilation but CLI started to fail. Probably because I have removed proper SDK.

After that I have googled about MSBuildSDKsPath and have set it manually (as it turned to be with extra trailing quote), and after that this extra quote prevented CLI to find proper SDK path whatever I tried to install, uninstall or reinstall.

Thus superposition of initial issue and mistakingly added quote when attempted to fix it led to such a weird error.

For now the issue can be closed, thanks a lot for the assistance.

Hi @IgorXq. Glad to hear you were able to get it working. I would like to understand your requirement of having to set MSBuildSDKsPath in your environment. It's generally not something that needs to be set as it forces MSBuild to use a particular path to look for SDKs; we primarily use it for our testing so that we can "override" where the SDKs live when building the .NET Core SDK locally.

If you're using VS 2017, you'll need a 2.2.1xx SDK (if you want to use 2.2). If you're using VS 2019, you'll need a 2.2.2xx SDK (2019 will install a 2.2.2xx SDK). I would probably have one of each installed to ensure both work. With that, you shouldn't need MSBuildSDKsPath set, so let me know if that's not the case.

For now, I'll close the issue, but if you do run into any problems, please do not hesitate to reactivate this issue or filing a new one! Thanks!

Hi @peterhuene !

I have never set MSBuildSDKsPath manually before I faced the issue, and everything worked fine.

I tried to set MSBuildSDKsPath in terms of fixing SDK issue (some similar issues on Stackoverflow suggested to set this variable in order to fix).

BR
Igor

I solved by setting MSBUILD_EXE_PATH as described here.

Instead if I set MSBuildSDKsPath that cause a different error "/app/Current/Microsoft.Common.props" ( seems paths mixed between sdk and compiling csproj )

Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
dotnet executable = [/usr/bin/dotnet]
PATH              = [/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
DOTNET_ROOT       = [/usr/share/dotnet]
MSBuildSDKsPath   = [/usr/share/dotnet/sdk/3.0.100/Sdks]
---> OpenProject
Msbuild failed when processing the file '/src/test/test.csproj' with message: The imported project "/app/Current/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
---> GetCompilation
has documents = False

deleted opend new

I got this error in my Azure pipeline, and added the following task to my yaml file to fix it:

- task: UseDotNet@2
  displayName: 'Use latest preview of .Net Core sdk 3.x'
  inputs:
    version: 3.x
    includePreviewVersions: true

Was this page helpful?
0 / 5 - 0 ratings