Sdk: visual studio 2017 .NET SDK does not support targeting .NET Core 2.0

Created on 2 Jan 2018  Â·  88Comments  Â·  Source: dotnet/sdk

have tried installing both professional and community version of visual studio 2017 v 15.5.2

and installed .net core Runtime 2.0.3 and .net core SDK 2.1.2.

When I open a new web application I get an error saying

"the sdk 'microsoft.net.sdk.web' specified could not be found"

When I try to build an existing project I get an error

"the current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0."

I don't see ".net core 2.0" in my target framework

I don't have global.json file in my computer

When I try dotnet --info, I get this

.NET Command Line Tools (2.1.2)
Product Information:

Version: 2.1.2

Commit SHA-1 hash: 5695315371

Runtime Environment:

OS Name: Windows

OS Version: 10.0.10586

OS Platform: Windows

RID: win10-x64

Base Path: C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

Version : 2.0.3

Build : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

Most helpful comment

Not sure why it is such a painful job targeting the dotnet runtime for each new version. still i can't understand :(

All 88 comments

.NET Command Line Tools (2.1.3)

Product Information:
Version: 2.1.3
Commit SHA-1 hash: a0ca411ca5

Runtime Environment:

Updated SDK to 2.1.3 and runtime to 2.0.4. still no luck.
latest dotnet --info:

OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.3\

Microsoft .NET Core Shared Framework Host

Version : 2.0.4
Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff

Which workloads are you installing with VS 2017?

This usually happens because you have an entry in your PATH environment variable pointing to a location that contains a version of dotnet.exe different from what you are installing.

Say, you have an entry to C:\Program Files (X86)\dotnet ahead of the C:\Program Files\dotnet entry. And you are installing an x64 version. In this case, VS will find the x86 version, which is not updated.

Can you verify that?

I had installed
.NET core cross platform development
asp.net and web development

I over came this problem by adding the sdk path to MSBUILDPATH variable in my user variables

Which path did you add to MSBUILDPATH?

Can you check your versions of the SDK and see if you have a 15.5 version in there? You would have if it you installed a nightly of the CLI or of VS a while ago. We have since then abandoned the 15.5 version and it would went out in nightlies and no official release.

I have seen the error you are reporting when folks had that SDK installed. Uninstalling it should solve it.

I am also going to close this issue since it seems you found a work around and I have a understanding of at least one variation of the problem. If this is not the case for you and something else is breaking you, please, just comment and I will re-activate the issue.

I have same issue. Can you explain this?? .NET Core 2.1 is not available in Visual Studio 2017.
I have tried uninstalling and reinstalling VS2017 as well as EVERY .net core SDK and runtime and then reinstalling all manually.

.NET Core 2.1 is available on command line to create projects. So it is definitely installed.
If I create the project and add it to my solution in VS2017, you still cannot target the 2.1 framework.

Microsoft Visual Studio Professional 2017
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556
Installed Version: Professional

@mlorbetske and @KathleenDollard regarding creating 2.1 projects in VS when the 2.1 SDK is installed in the box.

@livarcocc I have spent 4 hours now with Microsoft support and cannot get a resolution. I've uninstalled and reinstalled .net core libraries as well as VS2017. When I create a default project (class library), it tries to create a .NET Core 2.0 but get error:

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

dotnet --version and dotnet --info both return 2.1.4 for SDK and I can create projects via command line.
It is just Visual Studio that wont recognise them.

Can you tell me about MSBUILDPATH and PATH environment variables?
I added PATH variables (they were not defined) i.e. "Say, you have an entry to C:\Program Files (X86)\dotnet ahead of the C:\Program Files\dotnet entry. And you are installing an x64 version. In this case, VS will find the x86 version, which is not updated."

I do not have MSBUILDPATH.

It is strange that you did not have a PATH environment variable defined before. Would you mind sharing the contents of your PATH environment variable? And also the print out of dotnet --info?

Also, can you try building your netcoreapp2.0 project in the VS developer command prompt using msbuild, by running msbuild.exe? That should give you a bit more details on the error you are seeing.

Could you share the build output for it?

PATH variable is there - I was mistakenly looking at USER variables.

dotnet --info

.NET Command Line Tools (2.1.4)

Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.4\

Microsoft .NET Core Shared Framework Host

Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54

When building app, error says:

Severity Code Description Project File Line Suppression State
Error The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0. ClassLibrary2 C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets 112



netcoreapp2.0

ms-vs2017-netcore2issue

Cannot MSBUILD? Assume i need to add this to PATH variables.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319

for msbuild, open a developer command prompt and run msbuild.exe from there.

"C:\Users\Steve\Documents\Visual Studio 2017\Projects\ClassLibrary2\ClassLibrar
y2\ClassLibrary2.csproj" (default target) (1) ->
(_CheckForUnsupportedNETCoreVersion target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks
\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(112,5):
error : The current .NET SDK does not support targeting .NET Core 2.0. Either
target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports
.NET Core 2.0. [C:\Users\Steve\Documents\Visual Studio 2017\Projects\ClassLibra
ry2\ClassLibrary2\ClassLibrary2.csproj]

I cannot get any support from Microsoft without paying $US350 for incident. They say, this is not a core feature of Visual Studio 2017 so my MS Action Pack subscription is not valid for this incident. Go figure! .NET Core 2.0 is not a core feature!! Please!

Can you run the following two commands?

set COREHOST_TRACE=1
msbuild 2> resolverlog.txt

Then share the resolverlog.txt with us. Hopefully this will help shed a light into what is going on here.

set COREHOST_TRACE=1 msbuild > resolverlog.txt

Removed '2' from msbuild.

It seems your PATH environment variable is busted.

The resolver is failing with System.ArgumentException: Illegal characters in path. when trying to use the PATH to find dotnet.exe.

system-environment-variables
user-environment-variables

c:\Program Files (x86)\Microsoft SSDKs\TypeScript has a bunch of weird characters at the end of that line. question marks and what nots. There is a good chance that that's your culprit.

Same issue here. Trying to build Entity Framework Core from sources.
Running dotnet restore EFCore.sln gives the following error:

C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [C:\Projects\Github\EntityFrameworkCore\src\EFCore\EFCore.csproj]

I am also getting the below issues

Severity Code Description Project Line File Suppression State
Error The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. SqlServerCacheSample 135 C:\Program Files\dotnet\sdk\2.1.100-preview-007363\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets

Please help.

The environment variables are
image

Not sure why it is such a painful job targeting the dotnet runtime for each new version. still i can't understand :(

@d-saravanan the 2.1.4 and 2.1.100 SDKs cannot target .NET Core 2.1.
If you want to try out .NET Core 2.1 builds, you'd need to download CI builds of 2.1.300 from this repos's readme or wait for official previews to be released.

@dasMulli
For my understanding, could you let me know what's the difference between 2.1.300 compared to 2.1.3 which I already have installed.

Also, can you post on how to tell visual studio to use that path. I have been trying with the

MSBUILDPATH
and the
MSBuildSdksPath

but could not be able to get the desired version from neither the cli command / from within Visual Studio 2017 Community Preview V 15.6.0 Preview 5.0

dotnet --info

A few months ago the CLI increased its version number from 2.0.* to 2.1.* because it had new features: C# 7.2, newer NuGet and MSBuild versions. This seems logical from a semantic versioning point.

The builds that were supposed to support the upcoming .NET Core 2.1 had SDK version numbers of 2.0.0-*.

The problem is that the major and minor version numbers of the CLI ("SDK") and .NET Core aren't in sync and people got confused as to what it means ("I already have .NET Core 2.1" - "No, that's the SDK version, you're still using .NET Core 2.0 with a 2.1 SDK, the 2.2 SDKs will support .NET Core 2.1").

The new plan (https://github.com/dotnet/designs/pull/29). Is to keep major and minor version numbers of the CLI and the .NET Core runtime in sync, but without breaking existing 2.1.* SDK version schemes.
So the next SDK version following 2.1.4 is 2.1.100, 2.1.200 seems to be reserved for a possible release with newer tooling but without .NET Core 2.1 and the previously "2.2.0" versions are now "2.1.300".

So "2.1.300" is going to be the version that is going to support .NET Core 2.1.

Visual Studio uses its MSBuild distribution to load projects. MSBuild has "SDK Resolvers" that try to figure out what to do with Sdk="…" parts of your project files. If there are no environment variables set, the default SDK resolver will look for dotnet.exe on your PATH and resolve a .NET Core SDK installed along with it and use on-disk folders inside its Sdks subfolder.

So if the newest version of the .NET Core SDK / CLI you installed were 2.1.4, it would choose to import MSBuild tooling from C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk.

The presence of a global.json pinning an SDK version would affect his resolution behavior. So if I had both 2.1.4 and 2.99.9 (fictional) installed, it would choose the 2.99.9 version. If a global.json pinned the SDK version to 2.1.4 (so dotnet --version in that directory would bring 2.1.4) it would make VS' msbuild choose the 2.1.4 SDK path over 2.99.9.

In Visual Studio 15.6 it gets a little more complicated as it is also able to resolve SDKs from NuGet, so if you put Sdk="Microsoft.NET.Sdk;RoslynCodeTaskFactory/1.2.5" into the project file it would download RoslynCodeTaskFactory from NuGet.

@dasMulli Thanks for the detailed explanation. Hope this will be very helpful for anyone that is unable to understand the dotnet versioning problem. I am trying with 2.1.300

I've installed the daily build of .net core which is currently 2.1.300-preview2-008260 and running Visual Studio 2017 Version 15.5.7.

λ dotnet --info
.NET Command Line Tools (2.1.300-preview2-008260)

Product Information:
 Version:            2.1.300-preview2-008260
 Commit SHA-1 hash:  4f2e060ef3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300-preview2-008260\

Microsoft .NET Core Shared Framework Host

  Version  : 2.1.0-preview2-26131-06
  Build    : b13a0d5c331f374afd35ded57b9a4b4ab128864c

I've created a console project with dotnet new console and then I try to open this project from Visual Studio and here the message box I have:

image

The project compile fine, however, I've added the System.Memory 4.5.0-preview2-26225-02 NuGet package and tried the following code:

            var bytes = new byte[100];
            ReadOnlySpan<byte> sp = bytes;

The thing is ReadOnlySpan (same thing for Span) is marked as Obsoleted and I wonder if I should be worried or not...

When I got to the declaration of ReadOnlySpan<T> I have the following content:

// Decompiled with JetBrains decompiler
// Type: System.ReadOnlySpan`1
// Assembly: System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 701A02B4-9E86-401A-AF27-D0F5C13D74E1
// Assembly location: C:\Users\admin\.nuget\packages\microsoft.netcore.app\2.1.0-preview2-26131-06\ref\netcoreapp2.1\System.Runtime.dll

using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace System
{
  [IsByRefLike]
  [Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
  [IsReadOnly]
  public struct ReadOnlySpan<T>

It this whole thing normal or not? I thought I could have a pretty "work as it should" experience with .net Core 2.1 preview on this version of Visual Studio. Should it be the case or not?

Thanks!

@nockawa to use this version of the CLI, install the preview version of visual studio (currently a 15.6 preview version).

@dasMulli oh ok, thanks. I looked in the Visual Studio Installer to see if there was a preview listed, but there was not and thought that was it...
But indeed there's a new version of VS... I'm installing it right away! :) thanks!

I find this very confusing as well. I had been using 2.1.0-preview2-28189. But apparently it isn't on the nuget/myget servers anymore. So I upgraded to 2.1.0-preview1-final on all the packages, which worked great for everything but Microsoft.AspNetCore.All. That triggered the need to change the from netcoreapp2.0 to netcoreapp2.1. So by moving Microsoft.AspNetCore.All from version 2.1.0-preview1-final to 2.0.5, I was able to restore all my packages with no errors. I have not upgraded to the preview release of Visual Studio, although I did remove all previous releases of the .NET Core SDK (2.1.2 and 2.1.3), and install 2.1.4, adding it to the path.

Why are packages with "2.1" in them, such as 2.1.0-preview1-final, are targeting netcoreapp2.0?
Why are packages with the same versions, 2.1.0-preview1-final, targeting different frameworks?

Thank you to all the people who suffered before me and posted here. I thought I was losing it.

I got this same issue at a specific project.

I can create new apps at .Net Core 2.0, but for that project I was getting this message: "the current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0"

After some hours looking, I got the problem at global.json:

{ "projects": [ "src", "test" ], "sdk": { "version": "2.0.3" } }
This error was occurring 'cause a fresh installation of my windows and when I installed the new SDK, it didn't come with 2.0 version of SDK

Has this issue been fixed? I still can't choose .Net Core 2.1 from Visual Studio 2017 (15.7.2) after installing .Net Core 2.1.201

@maqsoodahmad .NET Core 2.1 is supported only a 2.1.300 and higher SDKs for which currently only an RC version is available at https://www.microsoft.com/net/download/all

See above comments for explanation

@maqsoodahmad

.NET Core SDK and runtime release independently to ensure you get features (especially tools) in a timely manner. This led to naming challenges. We attempted to use independent semantically version numbers, and created versions of the SDK labeled 2.1.n during that time. This caused massive confusion, we changed course (admitted mistake) and developed the plan of using 2.1.nmm. Unfortunately this meant we had to force two feature releases of .NET Core SDK (2.1.10x and 2.1.20x) into the new scheme prior to the release of .NET Core 2.1.0 Runtime. 2.1.10x and 2.1.20x can only target .NET Core Runtime 2.0.

Or put more simply, the decision to implement a system of having the first two positions of the SDK and runtime match had a rough start.

.NET Core 2.1 is in RC - it contains .NET Core Runtime 2.1.0 and .NET Core SDK 2.1.300

@dasMulli 's Feb 24 explanation is good on the what. I thought this might help with the why.

:( I really have tried everything i can.. and ready to just give up..

What am i doing wrong. @KathleenDollard , i have installed 2.1.300 as you said... dotnet --version does return "2.1.300-rc1-008673"

Why is VS 2017 still not recognizing it ??

I have uninstalled everything, installed .Net 2.1.300 and then VS 2017.. still no luck. Why is it so hard?? (am trying to keep calm, after messing a weekend)

image

which version of VS 2017 are you running? (current one is 15.7.3)
The released SDK currently is 2.1.300 (no RC) - https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.1.0-download.md

Be sure to check the cross-platform and web development workloads when installing / modifying VS.

Does dotnet new console -o testcons generate a 2.1 project? (TargetFramework set to netcoreapp2.1 in the csproj file) And can you run it using dotnet run?

Are there other locations containing a dotnet.exe on your PATH? (run where dotnet. it should only show these of your program files (+ x86 program files) folders)

@dasMulli thanks for quick response.

  1. Am on 15.7.2 of VS 2017 as i did not hit update.. now am updating it.
  2. dotnet new console -o testcons -> generate a 2.1 project
  3. where dotnet - > gives me following
    C:\Program Files\dotnetdotnet.exe
    C:\Program Files (x86)\dotnetdotnet.exe

So should upgrade of VS 2017 to 15.7.3 fix the issue or do you suggest anything else?

nope upgrade did not fix it.. may be i should create a fresh project with command line as you have it and do all the things.. that might work

@manuyareshimi I am sorry for your troubles. Thank you very much for helping us get to the bottom of this problem.

As this thread has gotten long, I need to ensure I understand what your core problem is:

  • If you create a new .NET Core project (say console) from Visual Studio, what is the TargetFramework in the .csproj file (assuming you are working in C#)?
  • If you open an existing Console project (like the one above if it is not already targeting 2.1) and you drop down the available runtimes, do you see .NET Core 2.1 as an option?

Thank you again for your patience.

@livarcocc Both for your info and since this issue is closed, would you prefer to reopen or start a new issue?

@manuyareshimi Do you have this file: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.dll"

If not, see this from @dasMulli :

Be sure to check the cross-platform and web development workloads when installing / modifying VS.

Start button -> Visual Studio Installer
image

@livarcocc I think we need to move the resolver into all workloads. We're adding better logging to the resolver right now, but we won't get a chance to even log if we're not installed.

I've been informed that we should already be installing the resolver in all workloads now, but I am checking if it is actually working. Please do let me know if you have that file and if that box is checked.

Thanks to @dasMulli , I am able to create a new project and move forward. I am not able to use an existing project of another dev. But its not blocking me for now.


@nguerrera , no i dont have .it (Net Core cross-platform development ) checked. I did not it existed.

@KathleenDollard ,
If you create a new .NET Core project (say console) from Visual Studio, what is the TargetFramework in the .csproj file (assuming you are working in C#)?
[Manu] - it is picking .Net Core 2.0
If you open an existing Console project (like the one above if it is not already targeting 2.1) and you drop down the available runtimes, do you see .NET Core 2.1 as an option?
[Manu] - it get .Net Core 1.0 to .Net Core 2.1

Thanks everyone for the help. My problem is resolved.

Added MSBUILDPATH environment variable with the value point to actually SDK path, then the issue is gone.

I seemed to have the same problem as @manuyareshimi
Creating a new project with the CLI worked as intended but changing a existing project did not.
Turned out to be that there was a _global.json_ file in the Solution roots folder that was targeting .Net Core 2.0.
Changed that one to target 2.1.300 worked for me.

To add to @Fredrik-Oberg comment...

global.json specifies an SDK

.NET Core SDK 2.1.300 can be used to target either .NET Core Runtime 2.0 or 2.1
.NET Core SDK 2.1.200 is the most recent SDK that can target only 2.0

If you used the newest version, then we can put 2.1.300-rc1-008673 into global.json. I have a working version at https://github.com/vietnam-devs/coolstore-microservice/blob/master/global.json

Hi, for anyone having this issue and couldn't track down which entry in the PATH variable was causing problems. Moving the C:\Program Files\dotnet\ entry to first position resolved the issue for me.

I was having this issue on our build server. I had installed the Visual Studio 2017 Build Tools, including the .NET Core Build Tools. From the shell on the build server, I was able to dotnet --info and see that the correct version of the build tools were installed, but I was still getting the error message.

After much trial and error, I decided to try installing the x86 version of the dotnet core SDK, and updating my PATH variables. This did the trick.

Eventually I realized that my build task was configured to use MSBuild x86, so I'm assuming this was the root cause of the issue.

I have the same issue, even with the stable 2.1 and preview 2.2RC runtimes, SDK.

As a consequence, now VS 2017 no longer detects updates available after I downloaded the latest 2.1 runtime exe

@livarcocc Any ideas here?

@livarcocc Any ideas here?

Did you try me recommendations?
stevomccormack commented on 7 Feb

My issues were directly related to corrupt environment variables - they were not corrupted manually by myself.

None of these options worked for me. Installing/reinstalling the sdk and runtime or the enviroment variables.

I got a project from GitHub and faced this issue (exactly as shown in some screenshot above that 2.0 is not available). Since I have been working with 2.0 in other local projects, I was sure that it is installed and working properly. Still, I downloaded the latest version of the SDK but still the same error.

As highlighted by @johnnycamby in his SO link, there was a local global.json in the project folders which was superseding the default system configuration. Manually updating the file resolved the issue.

just got this issue on windows 10, after installing the latest dot net core.

if I do a clean install of windows will this fix the issue?

@RevoluPowered I do not think you need to do a clean install of Windows.

When you said you installed the latest .NET Core, did you install the SDK?

Can you open a command prompt and type

dotnet --info 

and post the result here.

Can you check out this:
https://github.com/dotnet/cli/issues/8309#issuecomment-393965591
and
https://github.com/dotnet/cli/issues/8309#issuecomment-368225123

And can you open Visual Studio Help/About and post the version of VS you are using.

I can't get this info, it was broken and wasn't easily fixable so I had to reinstall because i have a tight deadline right now, had no time to investigate this issue properly, I hope you understand.

Not a problem. I just wanted to be sure you are unblocked.

same issue

@Karlheinzniebuhr Can you let us know what version of Visual Studio you have, and run

> dotnet --info

from a command prompt

Hi, I am running VS 2017 15.9.2 with .Net Core SDK 2.1.5 and Runtime 2.1.6 (all latest update version) but .Net Standard 2.1 is not showing up at Project properties, Application, Target Framework. Someone have some fix?

@crcaicedo netstandard2.1 does not exist yet and it will definitely not be supported by .NET Core SDK 2.1.500.

Did you mean netstandard2.0 or maybe netcoreapp2.1?

Many thanks @livarcocc !

I installed .Net Core 2.1 x64 SDK and x64 Runtime 2.1.6 from https://www.microsoft.com/net/download/visual-studio-sdks

how to use them?

@crcaicedo netstandard2.1 does not exist yet and it will definitely not be supported by .NET Core SDK 2.1.500.

Did you mean netstandard2.0 or maybe netcoreapp2.1?

@Karlheinzniebuhr Can you let us know what version of Visual Studio you have, and run

> dotnet --info

from a command prompt

.NET Core SDK (reflecting any global.json):
Version: 2.1.500
Commit: b68b931422

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x86

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.500
Commit: b68b931422

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.500\

Host (useful for support):
Version: 2.1.6
Commit: 3f4f8eebd8

.NET Core SDKs installed:
1.1.0 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

@crcaicedo your project needs to target netstandard2.0 if it is a library (in reality, it could target any of the lower netstandard versions as well) or you needs to target netcoreapp2.1 if it is an app.

Like so:

<TargetFramework>netcoreapp2.1</TargetFramework>

or

<TargetFramework>netstandard2.0</TargetFramework>

@Karlheinzniebuhr what happens if you try to build your project from the a developer command prompt using msbuild?

Many thanks again @livarcocc !! My project is a class library and target netstandard2.0

Sorry for the silly question, that implies that i cannot take advantage of latest 2.1 SDK? there are a way to do it?

@crcaicedo your project needs to target netstandard2.0 if it is a library (in reality, it could target any of the lower netstandard versions as well) or you needs to target netcoreapp2.1 if it is an app.

Like so:

<TargetFramework>netcoreapp2.1</TargetFramework>

or

<TargetFramework>netstandard2.0</TargetFramework>

@crcaicedo the version of you TargetFramework is not related to what version of the SDK you are using. Unless you have a global.json file pinning your SDK version to an older one, VS should be using the latest one already, without you having to do anything about it. The SDKs are compatible with older TargetFramework versions.

Zillion thanks for the explanation @livarcocc ! Have a nice day and a happy week!

@crcaicedo the version of you TargetFramework is not related to what version of the SDK you are using. Unless you have a global.json file pinning your SDK version to an older one, VS should be using the latest one already, without you having to do anything about it. The SDKs are compatible with older TargetFramework versions.

In case this helps someone else... After installing VS 15.9.2 my project that was working fine with 2.2 preview-3 stopped working. VS could not see the preview SDK. I could build the solution using dotnet.exe but not VS. To solve this I created a global.json at the root folder of this solution pointing to the preview sdk. That allowed VS to see the preview version. This is a change of behavior in VS between 15.8.x and 15.9.x.

@WillTartak That is https://blogs.msdn.microsoft.com/dotnet/2018/11/13/net-core-tooling-update-for-visual-studio-2017-version-15-9/

You can also check the box to allow previews from an RTM VS.

@nguerrera Thanks for the link. That makes sense. I think the global.json setup I did is a better approach than enabling it for everything. YMMV.

I had this problem and resolved it by deleting the global.json at the root of my project.
When I created a new class library in a new solution/project .net core 2.2 worked fine, but adding a .net core 2.2 project to an existing solution did not work because of the global.json at the root of that solution.

This issue is pretty maddening, there needs to be an official troubleshooting document for this.

@kkarakk There are actually several underlying issues in this thread, a few of which have documents, including corrupt paths and a misunderstanding about the way .NET Standard is versioned. Can you say a little more about your madding case, or create a new issue, and we are happy to help.

.NET Core SDK (reflecting any global.json):
 Version:   2.2.203
 Commit:    e5bab63eca

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.203\

Host (useful for support):
  Version: 2.2.4
  Commit:  f95848e524

.NET Core SDKs installed:
  1.1.12 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.2.203 [C:\Program Files\dotnet\sdk]

The order of environment variables seems to be correct.
In VS 2017 (Version 15.9.8) cannot see 2.2 in the TargetFx dropdown.

msbuild output:

  C:\Program Files\dotnet\sdk\2.1.504\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137
,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2.  Either target .NET Core 2.1 or l
ower, or use a version of the .NET SDK that supports .NET Core 2.2. [........csproj]

All class library projects fail to build with the same error ^^

I read this in the thread

your project needs to target netstandard2.0 if it is a library

Installed netstandard 2.0.3 lib from https://www.nuget.org/packages/NETStandard.Library

Same build errors..

Any suggestions?

@asunar See https://github.com/dotnet/sdk/issues/3124. You need 2.2.1xx for VS 2017.

Thanks @Pilchie .

Updating Visual Studio to version 15.9.12 fixed the problem.

Updating Visual Studio to version 15.9.12 fixed the problem.

Yes, it works!

This was a frustrating issue to track down and after doing all of the updates to VS and still not being able to install I tracked it down to an environment variable. Try removing MSBuildSDKsPath and see if that fixes your issue.

I only had to add MSBuildSDKsPath to my environment variables:
C:\Program Files\dotnet\sdk\2.1.806Sdks

Was this page helpful?
0 / 5 - 0 ratings