The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a .NET SDK that supports .NET Core 2.1

后端 未结 15 2401
攒了一身酷
攒了一身酷 2020-12-13 23:13

have tried upgrading to the professional version of visual studio 2017 v 15.6.0 (Preview 7.0)

and installed aspnetcore-runtime-2.1.0-preview1-final-win-x64 and .net

相关标签:
15条回答
  • 2020-12-13 23:42

    I am using Rider, I had

    The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2

    I had:

    $ dotnet --list-sdks
    2.1.2 [C:\Program Files\dotnet\sdk]
    2.1.202 [C:\Program Files\dotnet\sdk]
    2.1.505 [C:\Program Files\dotnet\sdk]
    2.1.602 [C:\Program Files\dotnet\sdk]
    2.2.202 [C:\Program Files\dotnet\sdk]
    

    I tried keeping only the latest sdk, and had:

    Project 'WebApplication3' load failed: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found..

    So I removed everything and reinstalled 2.1.602. Made a new project from Rider. And it worked. Cannot say I understood how I solved it...

    The issues for some peoples seems to be linked to global.json, see:
    - https://docs.microsoft.com/fr-fr/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio
    - https://docs.microsoft.com/fr-fr/dotnet/core/tools/global-json
    - https://andrewlock.net/the-sdk-microsoft-net-sdk-web-specified-could-not-be-found/

    Other things I did before (that did not seem to solve the issue but might have helped?):
    - Updating Rider from 2018.3.2 to 2018.3.4 (latest). - Installing Mono (was using the one from Unity when look into Rider build settings).
    - Tried to use custom MSBuild from Jetbrain (the one used for Linux) without success.
    - Installing everything related to .NET Core from VS installer.
    - Update VS community ot latest. - Reboot.

    In Rider/Build, Execution, Deployement/Toolset and Build I now have:
    Mono executable: C:\Program Files\Mono\bin\mono.exe
    - NET Core CLI executable: C:\Program Files\dotnet\dotnet.exe
    - Use MS Build version (Auto detected 16.0): C:\Program - Files\dotnet\sdk\2.1.602\MSBuild.dll

    0 讨论(0)
  • 2020-12-13 23:43

    Installing .NET Core SDK 2.1.300-preview2 did the trick for me:

    UPDATE: just in case, there is a newer version has been released recently. You can download the new .NET Core SDK for 2.2.0-preview1 (which includes ASP.NET 2.2.0-preview1) here.

    See also this answer when you are getting error like this in general:

    The current .NET SDK does not support targeting .NET Core 2.X

    0 讨论(0)
  • 2020-12-13 23:43

    I resolved the problem. the cause was that i installed

    • aspnetcore-runtime-2.1.0-preview1-final-win-x64 and
    • .net core SDK 2.1.4-x64 versions.
    • The installation placed the sdk files in c:\Program Files\dotnet
    • but VS2017 32bit was looking for the sdk files in c:\Program Files(x86)\dotnet.

    To resolve this i

    • installed the x86 version of the sdk and aspnetcore runtime,

    • set the MSBuildSDKsPath environmental variable to point to the new installation path.

    • deleted all obsolete sdks from control panel

    The question VS2017 Update 3 'Microsoft.NET.Sdk.Web' could not be found helped in resolving this issue.

    0 讨论(0)
  • 2020-12-13 23:43

    Go to your pipeline. Click on Edit pipeline. Click on the Agent Specification dropdown. Change it to Windows 2019. Click Save And Queue.

    And here you Go. It worked fine for me.

    0 讨论(0)
  • 2020-12-13 23:45

    I had this problem and I did a fresh install of VS2017. That fixed it!

    0 讨论(0)
  • 2020-12-13 23:47

    https://www.microsoft.com/net/download/visual-studio-sdks

    You can download the SDK from the above site

    check the SDK which is in your machine Path C:\Program Files\dotnet\sdk

    Change or check the target framework in visual studio,

    Right click on Startup Application or project => Application => Target Framework.

    You can change the framework and build the solution and restore nugget packages.

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