MSBUILD throws an error: the specified SDK "Microsoft.NET.Sdk" was not found

I am trying to build a solution using the msbuild command line and I keep getting this error:

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

The msbuild version is the latest in Microsoft Visual Studio 2017. I am using Windows Server 2012 R2 and the project is using .NET Core 2.0.

This is the command I use:

msbuild.exe /p:Configuration=Release /t:restore C:\Projects\MyProject.sln

Complete log:

  Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 9/16/2017 3:09:03 PM. Project "C:\Projects\MyProject.sln" on node 1 (restore target(s)). ValidateSolutionConfiguration: Building solution configuration "Release|Any CPU". Project "C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj" (2) on node 1 (restore target(s)). C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found. Done Building Project "C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj" (restore target(s)) -- FAILED. Build FAILED. "C:\Projects\MyProject.sln" (restore target) (1) -> "C:\Projects\Kernel\Kernel.csproj" (restore target) (2) -> C:\Projects\Kernel\Kernel.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found. 0 Warning(s) 11 Error(s) 
+26
c # msbuild .net-core
source share
4 answers

I ran into this error after playing with the installation of .Net Core 2.0 and seemingly messed it up. I would get the same error for dotnet restore , dotnet build or dotnet msbuild . In fact, everything related to .Net Core and msbuild.

The error occurred because the MSBuildSDKsPath environment MSBuildSDKsPath was still pointing to the old .Net Core 1.1 SDK.

To fix this problem, I manually set the MSBuildSDKsPath environment variable to specify the 2.0.0 SDK path, which for me with x64 was as follows: C:\Program Files\dotnet\sdk\2.0.0\Sdks .

Basically, if you have Sdk="Microsoft.NET.Sdk" in your .csproj , then a folder with the same name should exist in your MSBuildSDKsPath location.

+28
source share

Maybe you made a mistake also after installing .net core SDK 3.0, you should check the MSBuildSDKsPath environment variable after each installation of a new SDK. It should track the SDK that you use to create your project. I am using VS2017 with Windows 10.

for 2.2 SDK

 C:\Program Files\dotnet\sdk\2.2.104\Sdks 

to preview 3.0

 C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks 
0
source share

The same problem occurred while trying to install x64 .Net Core SDK Installer. The event the following dotnet --info shows me that the SDK was not found.

So, try installing the x86 .Net Core SDK installer. It can help you.

0
source share

I had the same problem and found a solution here: https://github.com/aspnet/AspNetCore/issues/3624

The solution is to simply have an x64 or x86 version of sdk / runtime / hosting. If you have both, and if you use, for example, the x86 version of dotnet.exe, it will not see the x64 version of the installed SDK.

The problem usually arises when installing a hosting package, since it includes both x86 and x64. Just delete the one you are not using.

0
source share

All Articles