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
Solution 1:
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.
Solution 2:
This happened to me after installing 2.2.100-preview3-009430 and then updating to Visual Studio 15.9.2.
I resolved by enabling the "Use previews of the .NET Core SDK" option.
Go to: Tools > Options > Projects and Solutions > .NET Core
Check the "Use previews of the .NET Core SDK" box
Restart Visual Studio and rebuild the solution.
VS Preview Options
Solution 3:
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
Solution 4:
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.
Solution 5:
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.