.NET6 - MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found
See original GitHub issue.NET6 - MSB4236: The SDK ‘Microsoft.NET.Sdk’ specified could not be found
Describe the bug
After installing .NET6 on Windows Server 2016 every project that I try to build on that machine fails due to MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found
To Reproduce
Install latest SDK (.NET6) and Runtime on Windows Server 2016. Doesn’t matter if I use .NET installer or binaries or even Visual Studio Build Tools 2022
Exceptions (if any)
On my local dev machine - Windows 10, everything works fine
Further technical details
This machine used to have all the previous .NET Core SDKs and Runtimes. I have uninstalled all of them so my machine is clean. I have also checked Environment Variables and they also look normal.
Windows Server 2016 dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.101\
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
.NET SDKs installed:
6.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (1 by maintainers)
Top Results From Across the Web
The SDK 'Microsoft.NET.Sdk' specified could not be found. ...
The SDK 'Microsoft.NET.Sdk' specified could not be found. in Visual Studio Community 2022 version 17.5 · Right-click your project > Unload ...
Read more >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 ......
Read more >MSB4236 The SDK Microsoft.NET.Sdk specified could not ...
The error was error MSB4236 The SDK Microsoft.NET.Sdk specified could not be found and is because the project now includes dotnetcore ...
Read more >Unable to locate the .NET SDK: The Reasons - Hamid Mosalla
Navigate to C:\Program Files\dotnet\sdk and see if you can find folders associated with different sdk versions. If you can't find any folder ...
Read more >Error under Debug "The SDK 'Microsoft.NET.sdk' specified ...
I have now downloaded msbuild tools and routed the correct path and tried again and the "'msbuild' not found" error seems to be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think I’ve found the cause of this problem.
My system environment variables contain an entry for
MSBuildSDKsPath
, which points toC:\Program Files\dotnet\sdk
. It looks harmless.In
C:\Program Files\dotnet\sdk\6.0.301\Current\SolutionFile\ImportAfter\Microsoft.NET.Sdk.Solution.targets
, the target definition/template references$(MSBuildSDKsPath)\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.Common.targets
, which resolves toC:\Program Files\dotnet\sdk\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.Common.targets
givenMSBuildSDKsPath
but there’s nothing there.Deleting that
MSBuildSDKsPath
from environment variables (and restarting affected terminals and IDEs to apply the change) fixed it for me.PS: I found out about this because when I did a
dotnet restore
and the error log became:Which explained what was happening much better, and pointed so much closer to the real issue in contrast to “SDK not found”. “Not found” is like the second hardest problem to solve than “A problem occurred”. Please fix this, if not the issue, the message.
Add the environment variable
MSBuildSDKsPath
with the value ofC:\Program Files\dotnet\sdk\6.0.402\Sdks\
(or whatever your sdk version is). Should do the trick!