Thursday 8 February 2018

Resolving “The SDK 'Microsoft.NET.Sdk.Web' specified could not be found”

While using .NET Core 2.0 you may run into errors which may not be clear. “The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.” is one such error which appears, when trying to load .NET Core 2.0 Web projects, and Let’s understand the reason behind this error to get it resolved.


Error:
When the solution was loaded in Visual Studio 2017 it did not show any message, but did not load the .NET Core 2.0 web projects. If tried to reload project, by right clicking on the project that was not loading below error message shown.

---------------------------
Microsoft Visual Studio
---------------------------
The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  D:\Users\chamindac\Documents\Source\Repos\bla\bla\src\APIs\xxx.csproj
---------------------------
OK  
---------------------------

The reason for this error is mismatch in the SDK of .NET Core 2.0 installed in the machine. The machine was installed with latest .NET Core 2.0 SDK, that is having number 2.1.4 as the version.

But the global.json file was saying required SDK is 2.0.0

How to resolve?
Changing the global.json to have version as 2.1.4 fixed the issue and projects could be loaded and built. But this project was done with a team and changing SDK decision, could not be made alone. The team was not ready to upgrade the SDK as they are not ready to take a risk.

The next approach was to find the exact version of SDK from somewhere and it was (and is) available in https://github.com/dotnet/core/blob/master/release-notes/download-archive.md
After installing SDK 2.0.0 the issue was resolved in a compatible way with the rest of the team.
Similar issue was discussed in a previous post here.

What happens if the solution opened in Visual Studio 2015?
Visual Studio 2015 is not compatible with .NET Core 2.0 and but it was giving a really misleading error, as shown below, if you try to reload a .NET Core 2.0 web project in VS 2015.

---------------------------
Microsoft Visual Studio
---------------------------
The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="
http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.  :\Users\chamindac\Documents\Source\Repos\bla\bla\src\APIs\xxx.csproj
---------------------------
OK  
---------------------------

Check the below links to understand the .NET Core 2.0 requirements.





No comments:

Popular Posts