137

I want to create a class library project with Target Framework .NET Standard 2.0.

I've updated my Visual Studio 2017 to Version 15.3 and also in Visual Studio installer checked .NET Framework 4.7 SDK and .NET Framework 4.7 targeting pack manually and installed them.

There is still no .NET Standard 2.0 option in the Target Framework combo box in the Project/Application window. So I changed TargetFramework tag in .csproj file manually to netstandard2.0, but after trying to build I get this error:

The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0.

3
  • 5
    Do you have a global.json file pinning your .NET Core SDK to 1.x? Have you installed the .NET Core 2.0 SDK separately? (I'd expect it to be included with VS, but it wouldn't hurt to install it anyway.) Commented Aug 17, 2017 at 10:11
  • 1
    @JonSkeet installing .NET Core 2.0 SDK separately worked. It will be good if you add your suggestion as an answer here. Commented Aug 17, 2017 at 10:51
  • 1
    Editing .csproj file and edit .net versions (remove all but net462) may solve this problem. Commented Nov 5, 2022 at 11:50

16 Answers 16

164

It sounds like installing the VS2017 update for that specific version didn't also install the .NET Core 2.0 SDK. You can download that here.

To check which version of the SDK you've already got installed, run

dotnet --info 

from the command line. Note that if there's a global.json file in either your current working directory or any ancestor directory, that will override which version of the SDK is run. (That's useful if you want to enforce a particular version for a project, for example.)

Judging by comments, some versions of VS2017 updates do install the .NET Core SDK. I suspect it may vary somewhat over time.

Sign up to request clarification or add additional context in comments.

17 Comments

@Marwie: To target netstandard2.0, I suspect you do. I haven't tried targeting that with the 1.0 SDK, but I wouldn't be surprised if it failed. You can still target netstandard1.X with the 1.0 SDK of course.
Ok - I'm new to the subject - I was surprised about the close relationship between .net core and .net standard - wasn't the reason to create .net standard to omit such dependencies? Why wouldn't it ship in a separate package?
@Marwie: Well, .NET Core SDK is separate from the .NET Core Runtime, which is separate from the .NET Standard. But the SDK "knows about" a set of target frameworks, and I'm not surprised that it won't work with a future one. It's like expecting Visual Studio 2013 to compile C# 7 code. While it would possibly be feasible for MS to have engineered it so that you didn't need the .NET Core 2.0 SDK to target netstandard2.0, it would be an odd use case to want that anyway, IMO.
I received the error after i uninstalled all the .net Core 1.x SDKs. I still had Microsoft. .NET core SDK 2.0.2, 2.0.3, 2.1.1 and 2.1.2 installed and VS 2017 5.2. Once I did a manual install of the current Microsoft. .NET core SDK (2.1.3) I could again compile my projects. I wonder what in removing the 1.x SDKs broke the 2.x SDKs.
@Justin: Okay, so that sounds like either the 2.1.4 SDK hasn't installed properly, or you've got a global.json file pinning it to an old version.
|
28

while the above answers didn't solve my problem. I finally solved it by specifically going to this link https://www.microsoft.com/net/download/visual-studio-sdks and download the required sdk for Visual Studio. It was really confusing and i don't understand why but that solved my problem

2 Comments

I can't just upvote this, this also resolved my problem too but I hope someone clarifies the reason behind this working.
This solution worked for me as well. For me it was a matter of incompatibility with the latest SDK. If you're using Visual Studio 2017, you can't use the latest version of the .NET Core SDK.
15

This happens sometimes when I'm trying to open my old projects, what helps me is to change projects target framework. Go to Project -> projectname Properties... and change the Target framework to the one that you have installed. Project properties

1 Comment

The drop-down menu doesn't show anything for me. Any ideas?
13

For me the solution was to change the version in global.json to reflect the installed one.

Like the others said the version can be found running dotnet --info in cmd

This:

{ "projects": [ "src", "test" ], "sdk": { "version": "2.0.3" } } 

Became:

{ "projects": [ "src", "test" ], "sdk": { "version": "2.1.4" } } 

You can also create the global.json file by running

dotnet new globaljson --sdk-version 2.1.4 

at root of project

5 Comments

Where would that global.json file be found if it would exist?
I think ms removed that file, check your .sln and .csproj files :)
The file global.json would be next to the solution file. I typically have included as a solution item in the solution itself. I found in my experiments that without closing and reloading the solution, changing the version in global.json can lead to strange build errors. My comment applies to VS2018, version 15.9.2, with .NET Core SDK 2.2.100.
From the docs .NET Core SDK looks for a global.json file in the current working directory ... or one of its parent directories. So like an inheritance type file.
Your "dotnet new globaljson" worked for me in Mac OS. Thanks.
12

This worked for me

Use the installation of the Visual Studio

On the tab "Workloads" check ".Net Core cross-platform development" and click on "Modify"

enter image description here

Don't forget to check ".NET Core 2.0 development tools" on the left menu.

Source

Note

I installed the Asp Net Core before, however not appeared on my Visual Studio, just after I installed using the installation of Visual Studio appeared for me.

1 Comment

Alternatively, you can install what you need from here: dotnet.microsoft.com/download/…
7

I had installations of both Visual Studio 2019 and 2017. I tried installing the .NET Core 2.X SDK for VS2017 separately but with no luck.

The issue is, that I have .NET Core 3.0 SDK installed as default sdk-version, which VS2017 does not like.

My solution was to switch the SDK version for the specific project.

  • First, list your installed SDK's to find the desired version:
$ dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.1.100 Commit: cd82f021f4 Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.100\ Host (useful for support): Version: 3.1.0 Commit: 65f04fb6db .NET Core SDKs installed: 1.1.14 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.509 [C:\Program Files\dotnet\sdk] 2.2.110 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk] 
  • From your solution directory:
$ dotnet new globaljson --sdk-version 2.2.110 --force 

Now, dotnet will use the specified SDK version for this solution.

I have not found a way to do this system-wide without also messing up my 3.0 projects.

2 Comments

It seems strange that this should be necessary, but greating a global.json (for version 2.1.513) solved my problem too.
I was getting the exact same error but on a MacBook Pro after upgrading to Visual Studio for Mac 2022. Your dotnet command solved it for me. My error message was: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
3

When I upgraded Visual Studio to version 15.5.1, .Net Core SDK was upgraded to 2.X, so this error went away. When I run dotnet --info, I see the following now:

enter image description here

Comments

3

I just had this with 15.8.3 after uninstalling some .NET Core 1.x preview SDKs, my application would not compile and showed the error.

It was fixed by installing the latest x86 version of the SDK even though I'm on Windows 10 x64.

I presume this is because VS 2017 is still a x86 program and though the programs run as x64 the compiler was looking for an appropriate x86 SDK

Comments

2

Actually, to me it happened in opposite way to another answers.

I did install the latest .NET Core SDK before the issue appeared (3.0.0-preview2 in my case) having not the latest version of Visual Studio (not sure if that would make any difference).

So, the solution was just to uninstall that latest .NET Core SDK. (This is not perfect if you need it, so you might consider Visual Studio upgrade to the latest one, but at least that solved ongoing issue).

Comments

2

I had the same problem and I solved this way:

  1. Installed the .NET Core 2.2 SDK for Visual Studio 2017. You can download it from this link: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral
  2. Went to the project -> Properties > Target Framework

And now I the 2.0 missing target framework was eligible, I selected it and the problem was solved.

Comments

1

I just went through this trouble. In my case I had a working script

SET devenvPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe "%devenvPath%" mySolution.sln /Rebuild "DebugWithUT|AnyCpu" /Out mySolution.Build.log 

Today I started getting this exact error. But now I remember installing VS2019 day before. Looks like it changed something for VS2017. I went to VS2017 Update, installed latest version/update and it fixed it back.

Comments

1

make sure you download the x86 SDK instead of only the x64 SDK for visual studio.

1 Comment

This is a duplicate of an older answer!
0

I had same problem, and have the latest ver Microsoft Visual Studio Community 2017 Version 15.7.3

I just downloaded the latest SDK 2.1 and no more targeting issue. https://www.microsoft.com/net/download/thank-you/dotnet-sdk-2.1.301-windows-x64-installer

Info: Microsoft Visual Studio Community 2017 Version 15.7.3 VisualStudio.15.Release/15.7.3+27703.2026 Microsoft .NET Framework Version 4.7.03056

Installed Version: Community

C# Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

NuGet Package Manager 4.6.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

Visual Basic Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Unity 3.7.0.1 Visual Studio Tools for Unity

1 Comment

What is all the additional information for, and where does it come from? Please provide a source and a reason you wrote it all down.
0

I had the same problem as the current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1

1) Make sure .Net core SDK installed on your machine. Download .NET!

2) set PATH environment variables as below Path

Comments

0

I had this issue while trying to build my solution in TFS. We were using "dot net publish" task. Using msbuild broke the ice for us.

Comments

0

I fought this problem for days, and what I concluded was that one of my SDK versions was broken.

For example I had 6.0.308 and 6.0.309 installed (in addition to 2.1). What ultimately seemed to fix it was to uninstall (via Add/Remove Programs) 6.0.309, then uninstall 6.0.308 (I had to reinstall it and then remove it -- which I couldn't do with 6.0.309 still installed), then I installed 6.0.310. Not sure exactly which of those worked, but uninstalling/reinstalling the 2.1 versions did not help, only those 6.0 versions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.