blog post image
Andrew Lock avatar

Andrew Lock

~6 min read

The SDK 'Microsoft.Net.Sdk.Web' specified could not be found

This article describes why you get the error "The SDK 'Microsoft.Net.Sdk.Web' specified could not be found" when creating a new project in Visual Studio 2017 15.3, which prevents the project from loading, and how to fix it.

tl;dr; I had a rogue global.json sitting in a parent folder, that was tying the SDK version to 1.X. Removing that, (or adding a global.json for 2.x fixed the problem).

Update: Shortly after publishing this post, I noticed a tweet from Patrik who was getting a similar error, but for a different situation. He had installed the VS 2017 15.3 update, and could no longer open ASP.NET Core 1.1 projects!

It turns out, he'd uncovered the route of the problem, and the issue I was having - VS 2017 update 3 is incompatible with the 1.0.0 SDK:

Kudos to him for figuring it out!

2.0 all the things

As I'm sure anyone who's reading this is aware, Microsoft released the final version of .NET Standard 2.0, .NET Core 2.0, and ASP.NET Core 2.0 yesterday. These brings a huge number of changes, perhaps most importantly being the massive increase in API surface brought by .NET STandard 2.0, which will make porting applications to .NET Core much easier.

As part of the release, Microsoft also released Visual Studio 2017 update 3. This also has a bunch of features, but most importantly in supports .NET Core 2.0. Before this point, if you wanted to play with the .NET Core 2.0 bits you had to install the preview version of Visual Studio.

That's no longer as scary as it once was, with VS new lightweight installer and side by side installers. But I've been burned one to many times, and just didn't feel like risking having to pave my machine, so I decided to hold off the preview version. That didn't stop me playing with the preview bits of course, OmniSharp means developing in VS Code and with the CLI is almost as good, and JetBrains Rider went RTM a couple of weeks ago.

Still, I was excited to play with 2.0 on my home turf, in Visual Studio, so I:

  • Opened up the Visual Studio Installer program - This should force VS to check for updates, instead of waiting for it to notice that an update was available. It still took a little while (10 mins) for 15.3 to become available, but I clicked the update button as soon as it was available

  • Installed the .NET Core 2.0 SDK from here - You have to do this step separately at the moment. Once this is installed, the .NET Core 2.0 templates will light up in Visual Studio.

With both of these installed I decided on a quick test to make sure everything was running smoothly. I'd create a basic app using new 2.0 templates.

Creating a new ASP.NET Core 2.0 web app

The File > New Project experience is pretty much the same in ASP.NET Core 2.0, but there are some additional templates available after you choose ASP.NET Core Web Application. If you switch the framework version to ASP.NET Core 2.0, you'll see some new templates appear, including SPA templates for Angular and React.js:

New ASP.NET Core web application

I left everything at the defaults - no Docker support enabled, no authentication - and selected Web Application (Model-View-Controller).

Note that the templates have been renamed a little. The Web Application template creates a new project using Razor pages, while the Web Application (Model-View-Controller) template creates a template using separate controllers.

Click OK, and wait for the template to scaffold… and …

Visual Studio broken

Oh dear. What's going on here?

The SDK 'Microsoft.Net.Sdk.Web' specified could not be found

So, there was clearly a problem creating the solution. My first thought was that it was a bug in the new VS 2017 update. A little odd seeing as noone else on Twitter seemed to have mentioned it, but not overly surprising given it had just been released. I should expect some kinks right?

A quickgoogling for the error, turned up this issue, but that seemed to suggest the error was an old one that had been fixed.

I gave it a second go, but sure enough, the same error occurred. Clicking OK left me with a solution with no projects.

Solution view

The project template was created successfully on disk, so I thought, why not just add it to the solution directly: Right Click on the solution file Add > Existing Project?

Error adding

Hmmm, so definitely something significantly wrong here...

Check your global.json

The error was complaining that the SDK was not found. Why would that happen? I had definitely installed the .NET Core 2.0 SDK, and VS could definitely see it, as it had shown me the 2.0 templates.

It was at this point I had an epiphany. A while back, when experimenting with a variety of preview builds, I had recurring issues when I would switch back and forth between preview projects and ASP.NET Core 1.0 projects.

To get round the problem, I created a sub folder in my Repos folder for preview builds, and dropped a global.json into the folder for the newer SDK, and placed the following global.json in the root of my Repos folder:

{
  "sdk": {
    "version": "1.0.0"
  }
}

Any time I created a project in the Previews folder, it would use the preview SDK, but a project created anywhere else would use the stable 1.0.0 SDK. This was the route of my problem.

I was trying to create an ASP.NET Core 2.0 project in a folder tied to the 1.0.0 SDK. That older SDK doesn't support the new 2.0 projects, so VS was borking when it tried to load the project.

The simple fix was to either delete the global.json entirely (the highest SDK version will be used in that case), or update it to 2.0.0.

In general, you can always use the latest version of the SDK to build your projects. The 2.0.0 SDK can be used to build 1.0.0 projects.

After updating the global.json, VS was able to add the existing project, and to create new projects with no issues.

Visual Studio working

Summary

I was running into an issue where creating a new ASP.NET Core 2.0 project was giving me an error The SDK 'Microsoft.Net.Sdk.Web' specified could not be found, and leaving me unable to open the project in Visual Studio. The problem was the project was created in a folder that contained a global.json file, tying the SDK version to 1.0.0.

Deleting the global.json, or updating it to 2.0.0, fixed the issue. Be sure to check parent folders too - if any parent folder contains a global.json, the SDK version specified in the "closest" folder will be used.

Andrew Lock | .Net Escapades
Want an email when
there's new posts?