Reputation: 8233
I have installed dotnet-sdk-3.0.100-win-x64.exe in my system to targeting .NET Core 3.0 application. Post installation I validated the installed version using the command : dotnet --version which is giving response = 3.0.100.
Now using dotnet cli I tried to create a classlibrary(C#) with targetframework=netstandard2.1 and also created a solution and added the classlibrary project to it.
On building the solution I see the following error:
Error NETSDK1045 The current .NET SDK does not support targeting .NET Standard 2.1. Either target .NET Standard 2.0 or lower, or use a version of the .NET SDK that supports .NET Standard 2.1. SampleApp C:\ProgramFiles\dotnet\sdk\2.2.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets
Can anyone help me to fix this issue?
Upvotes: 0
Views: 815
Reputation: 169340
Make sure that you don't have a global.json
file in the current working directory or one of its parent directories.
It is used to define which .NET Core SDK version is used when you run .NET Core CLI commands. In your case, 2.2.300
is apparently used. If there is no global.json
, the latest SDK installed on the machine should be used.
You can try to run this command just before you build to to create a new the global.json
file in the current directory
dotnet new globaljson --sdk-version 3.0.100
Note that you need Visual Studio version 16.3 or greater to work with .NET Core 3. If it complains about MSBuild, try to update Visual Studio or/and see this issue on GitHub.
Upvotes: 0