'Visual studio 2017 Update 3 - The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
Error:
C:\WebApp\WebApp.csproj : error : The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. C:\WebApp\WebApp.csproj
I am trying to open Dotnet core project and I am getting the above error.
I have installed the latest SDK from https://www.microsoft.com/net/core#windowscmd
I have checked the path for dotnet cmd and it works fine.
Am I missing something? Let me know if you need more information.
The target framework is set to .NET 4.5.2
Solution 1:[1]
I stumbled upon this issue a number of times recently. Here's a brief list of the workaround I found (one of them always worked until now):
- Install the right .NET Core SDK: Either the latest version or the version required by your project.
- Clean-up obsolete .NET Core versions: Go to Control Panel and uninstall previous .NET Core SDK/Runtime versions (as long as you don't use them anymore).
Create a Global.json file: Add a new global.json file to your project's root with the following content (replace the .NET Core version build with the one you want to run the project with):
{ "sdk": { "version": "2.0.5" } }
Rename the SDK reference: Open your
.projfile and replace<project sdk="Microsoft.NET.Sdk.web">with<project sdk="Microsoft.NET.Sdk">.Add the MSBuildSDKsPath Environment Variable: The dotnet CLI sets the MSBuildSDKsPath environment variable when invoking MSBuild: however, a December 2016 patch changed the CLI behaviour so that it will respect an existing environment variable, if it has already been set: this will allow the developer to “force” the CLI to use a specific SDK.
- Check your PATH: Verify that both
C:\Program Files\dotnetandC:\Program Files (x86)\dotnetare in the PATH environment variable.
For additional info regarding the issue and other viable fixes check out this blog post that I wrote on this topic.
Solution 2:[2]
I agree with the comment on Sundeep's answer, you shouldn't have a global.json file in your project anymore.
It seems as though installing the .NET Core 2.0 SDK is causing issues with the PATH. Verify that C:\Program Files\dotnet and C:\Program Files (x86)\dotnet are in the PATH environment variable. In my case, these values were already present under System Variables so I added them to User Variables and rebooted my machine. This resolved my issue.
Solution 3:[3]
I've encountered the same problem, I just rename <project sdk="Microsoft.NET.Sdk.web"> to <project sdk="Microsoft.NET.Sdk"> on csproj
another situation: https://stackoverflow.com/a/55529011/2971851
issue details: 2.1.6xx & 2.2.2xx version of the SDKs are only supported on Visual Studio 2019. VS 2017 needs 2.1.5xx & 2.2.1xx versions of the SDK.
How to fix the issue? Install 2.1.5xx version of the SDK if you are targetting a 2.1 app Install 2.2.1xx version of the SDK if you are targetting a 2.2 app.
and according to the official document:
Note: If you are a Visual Studio user, there are MSBuild version requirements so use only the .NET Core SDK supported for each Visual Studio version. If you use other development environments, we recommend using the latest SDK release.
Solution 4:[4]
Do not uninstall previous SDK versions!
When I followed the 2nd step suggested in Darkseal's answer, uninstalling the previous SDK versions, it caused an "expected imports are missing" fatal error every time I opened up my project, so I needed to repair my Visual Studio, since installing the old SDK versions again kept popping up this error...
Also the other steps mentioned in that answer did not make any difference (both dotnet references were present in the environment variables and MSBuildSDKsPath was not needed for me).
Install the proper SDK version and select it in the Solution's Properties
As Jyoten mentioned I was using VS2017 x86 version and my SDKs were x64.
However, this was not the only issue, it seems there's some incompatibility with some SDK versions and VS2017. Having installed SDK v2.2.203 and v2.2.202, they would never showed up in the Target framework dropdown when I double-clicked the Properties on my project's solution (in the Solution Explorer (Ctrl+Alt+L)).
So I needed to install v2.2.105 x86 as mentioned in this answer, for it to show up in that dropdown.
Once it did, the solution that was requiring .NET Core v2.2 worked properly (did the Build normally).
Solution 5:[5]
I had this issue when I had to open a .Net Core 1.0.4 project in VS2017.
When I installed 1.0.4 SDK, i chose the x64 version which placed the sdk files in 'c:\Program Files\dotnet' ...
but my VS2017 was 32bit and was therefore looking for the sdk in 'c:\Program Files (x86)\dotnet'.
Once I installed the 32 bit version of the SDK it worked fine.
Solution 6:[6]
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.
Solution 7:[7]
I was getting this error in Visual Studio Code.
I was able to find the issue by setting the OmniSharp log settings in VS Code to debug. Once I did that I could see that it wasn't finding Microsoft.Build.Resources.dll.
I installed MS Build by repairing my VS 2017 Community installation. That fixed it.
Solution 8:[8]
uninstall and reinstall microsoft .NET core SDK. then restart visual studio. this works for me.
Solution 9:[9]
Choose the proper SDK according to your Visual Studio and Operating System. I downloaded the correct version from here https://dotnet.microsoft.com/download/visual-studio-sdks and after that .Net Core appeared in target frameworks list (there is a strict dependence between sdk version and VS version, so be careful).
Solution 10:[10]
I have solved this issue by, go to this site, https://dotnet.microsoft.com/download In that, install both .NET Core Runtime and .NET Core SDK. After you install that, Open the Visual Studio 2017 with an administrator, Now The problem has been gone?
Solution 11:[11]
I edited the .csproj file and changed netcoreapp2.2 to netcoreapp2.1 in this stanza & then I was able to get it working.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
Solution 12:[12]
Install the proper SDK version and go to below links
https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.403-windows-x64-installer https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.9-windows-x64-installer
Solution 13:[13]
This worked for me:
- Make sure that the .NET folder where SDKs are and Visual Studio are in the same program files (x86) or program files.
- Provide the path to the SDK in the environment variable.
Solution 14:[14]
If anyone else stumbles upon this issue (including future me), I had the same problem and tried literary every solution proposed here and nothing worked. Finally what fixed the issue for me was deleting NuGetFallbackFolder in C:\Program Files\dotnet\sdk.
After deleting that folder, everything just started to work magically.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
