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 2400
攒了一身酷
攒了一身酷 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:28

    It looks like Microsoft are encouraging better coding practice for those early adopters of latest development software in Net Core 2.1 by removing the capability to use older software where bad habits prevail. Net Core 2.0 and the older versions are almost end of life so should not be being used at all. (https://blogs.msdn.microsoft.com/dotnet/2018/06/20/net-core-2-0-will-reach-end-of-life-on-september-1-2018/)

    1) Microsoft have removed ServiceLocator since widely considered an anti-pattern resulting in difficult to understand code.

    2) To improve MVC applications, the AccountController was removed from Authentication/Authorization to encourage use of Razor pages which implement the Single Responsibiity Principle.

    It would not be considered best practice to circumvent these changes in order to increase perpetuation of software built to lower software engineering standards in the past.

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

    Same happened to me, but then for version 2.2 of .NET Core. I installed the latest version of .NET Core 2.2 SDK, which was 2.2.202 at that time. Visual studio allowed me to create a new project for Core 2.2, but it was showing the error:

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

    The target framework for my project was empty and the dropdown didn't show 2.2.

    After installing .NET Core SDK 2.2.103, the error was gone and the dropdown did show ".NET Core 2.2".

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

    I started getting this error after I installed SDK 2.2.300. After reading this post and some other I downgrade it to SDK 2.2.1xx and the error went away. Note: I had to uninstall SDK 2.2.300 and restart after installing SDK 2.2.1xx.

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

    Check to make sure you don't have global.json file in your project root folder that forces your project to use .NET SDK 2.1 only.

    If you have this global.json file, delete it, and then restart visual studio.

    As embarrassing as it might sound, I spent almost an hour tinkering and I even downloaded several SDK version to force it to use 2.2

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

    The problem here is that Microsoft confused a whole lot of people with how they numbered their .NET Core SDKs.

    In the original poster's message the path C:\Program Files\dotnet\sdk\2.1.100\ DOES NOT appear to represent the .NET Core 2.1 runtime (but you'd think it does).

    I came across this post The current .NET SDK does not support targeting .NET Core 2.1 on developercommunity.visualstudio.com where a Microsoft support person explains the confusion:

    "Thank you for your feedback! We have determined that this issue is not a bug. The first SDK with .NET Core 2.1 support is 2.1.300-preview1. We know the versioning is confusing which is why starting in 2.1.300, the major.minor versions of the SDK will now be aligned with the major.minor versions of the runtime as well."

    So ... in order to get .NET Core 2.1 support for building via the SDK you need to install the SDK with version 2.1.300 at least (since 2.1.2 is NOT .NET Core 2.1) ... yeah, confusing. Thank you Microsoft for some lost time on this.

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

    I also solved the problem in this way:

    Check versions on dotnet sdk available

    C:\Users\me>dotnet --list-sdks
    
     ##2.1.202 [C:\Program Files\dotnet\sdk]
     ##2.1.505 [C:\Program Files\dotnet\sdk]
     ##2.1.508 [C:\Program Files\dotnet\sdk]
     ##2.1.509 [C:\Program Files\dotnet\sdk]
     ##2.1.511 [C:\Program Files\dotnet\sdk]
     ##2.1.514 [C:\Program Files\dotnet\sdk]
     ##2.1.801 [C:\Program Files\dotnet\sdk]
    
    

    I tested my build on all of those versions and it does not work until I uninstalled all of the above from Programs and Features. Then download from the latest:

    https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.300-windows-x64-installer
    

    This worked. Dont waste time like i did just install latest version of dotnet sdk and you good to go. "

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