msbuild: error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
I’m trying to build a solution using msbuild command line and I keep getting this error:
error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
The version of msbuild is the latest from microsoft visual studio 2017 tools. I’m using Windows Server 2012 R2 and the project uses .NET Core 2.0.
This is the command that I’m using:
msbuild.exe /p:Configuration=Release /t:restore C:\Projects\MyProject.sln
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 43
- Comments: 58 (19 by maintainers)
Commits related to this issue
- repro for bug https://github.com/microsoft/msbuild/issues/2532 — committed to devel0/repros by devel0 5 years ago
- Added COREHOST_TRACE=1 as suggested in [msbuild github](https://github.com/Microsoft/msbuild/issues/2532) — committed to smaillet/Llvm.NET by smaillet 4 years ago
I fixed this by creating a path variable “MSBuildSDKsPath” with the value “C:\Program Files\dotnet\sdk\2.0.0\Sdks”
I don’t know why msbuild can’t find this path by default, but this fixed the issue for us
Make sure to install the .NET Core workload:
Anyone who’s still having trouble here, could you try unsetting
MSBuildSDKsPathand see if the issue still repros. If it does, could you setCOREHOST_TRACE=1, reproduce the issue, and then paste the trace output here?If you have Build tools SKU:
If you have full VS:
You can get Microsoft.NET.Sdk to resolve without the .NET Core or ASP.NET workloads installed, but it will be locked to version 1.x instead of resolving the latest version or global.json implied version.
You cannot get Microsoft.NET.Sdk.Web to resolve without the .NET Core workload or ASP.NET workloads installed.
Is everyone reporting this using “Build Tools for Visual Studio 2017” https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
rather than full VS?
I ran OmniSharp with
COREHOST_TRACE=1as suggested by @DustinCampbell and could see the following messsageFWIW, on my machine, dotnet in installed in
/usr/lib64/dotnetand has a link in/usr/bin. I looked inside the/usr/local/bindirectory and found a dead symbolic link/opt/dotnet. I removed the symbolic link, and MSBuild now properly resolves the SDK.The only solution that worked for this was this comment: https://github.com/dotnet/docfx/issues/1752#issuecomment-323385945
So basically I needed to add the config and change the MsBuild Path to the one inside the SDK, not use the MSBuild that’s part of Visual Studio 2015.
Just a FYI, it might help somebody else. Our setup:
error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be foundWhat helped:
.NET Core build tools, as suggested by @nguerreraWithout restarting the agent it will still fail…
@fanicia thank you!!!
@venkateswaris
If you install via choco, you need to include workloads you would normally include via the GUI:
https://github.com/dotnet/msbuild/issues/2532#issuecomment-343578403
For me, I used this choco command:
@venkateswaris The official way to install the .NET Core workload is either through the Build Tools installer UI or its command line options. Documentation for the command line is here and a list of workloads for the Build Tools installer is here. In your case you probably want to ensure that the
Microsoft.VisualStudio.Workload.NetCoreBuildToolsworkload is installed.Workload selection applies to full VS as well:
Tried first MSBuildSdksPath no success Updated the build tools 2017 to latest version did not work also Copying my local VS 2017 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\SdkResolvers to build server solved for me the issue also!
Ideally an update for build tools for visual studio 2017 package should fix this
For some reason .NET Core 3 preview’s MSBuild.dll breaks it again and I have to set the path (
MSBUILD_EXE_PATH) to 2.2. (I’m using @RSuter fix). I’m using MSBuild API to load the projects and it fails ifMSBUILD_EXE_PATHis set to 3.0 MSBuild.dll@nguerrera Thanks. That was indeed our problem on server2, it was missing the .net core workload. After including it, it works fine!
To clarify. I was also in the case where i was able to build with
dotnet build, butmsbuild /t:rebuilddidn’t work