Visual studio 2017 Update 3 - The SDK 'Microsoft.NET.Sdk.Web' specified could not be found

前端 未结 14 960
暖寄归人
暖寄归人 2020-12-13 07:06

Error:

C:\\WebApp\\WebApp.csproj : error : The SDK \'Microsoft.NET.Sdk.Web\' specified could not be found. C:\\WebApp\\WebApp.csproj

相关标签:
14条回答
  • 2020-12-13 07:10

    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.

    0 讨论(0)
  • 2020-12-13 07:12

    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).

    0 讨论(0)
  • 2020-12-13 07:13

    This worked for me:

    1. Make sure that the .NET folder where SDKs are and Visual Studio are in the same program files (x86) or program files.
    2. Provide the path to the SDK in the environment variable.
    0 讨论(0)
  • 2020-12-13 07:17

    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.

    0 讨论(0)
  • 2020-12-13 07:22

    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):

    1. Install the right .NET Core SDK: Either the latest version or the version required by your project.
    2. 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).
    3. 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" } }

    4. Rename the SDK reference: Open your .proj file and replace <project sdk="Microsoft.NET.Sdk.web"> with <project sdk="Microsoft.NET.Sdk"> .

    5. 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.

    6. Check your PATH: Verify that both C:\Program Files\dotnet and C:\Program Files (x86)\dotnet are 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.

    0 讨论(0)
  • 2020-12-13 07:22

    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.

    0 讨论(0)
提交回复
热议问题