29

I have already installed VS2017 Enterprise 15.6.4. Recently installed .NET Core 2.1.101 SDK from official site

I was expecting .NET Core 2.1 as one of the target framework available if I create console or asp.net core application. Can someone help me understanding what I am missing here.

As suggested in comments, I installed 15.7 preview 2. Still no luck and same issue.

enter image description here

rahulaga-msft
  • 3,964
  • 6
  • 26
  • 44
  • .NET Core 2.1 came out *after* 15.6.1. It's only available in the 15.7 previews. The SDK you downloaded is about 2.0 too. The SDK that targets Core 2.1 is [2.1.300-preview1](https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1) – Panagiotis Kanavos Apr 03 '18 at 12:06
  • @PanagiotisKanavos : you mean vs2017 15.7 preview version ? – rahulaga-msft Apr 03 '18 at 12:07
  • Version*s*. It's at 15.7 Preview 2 now – Panagiotis Kanavos Apr 03 '18 at 12:08
  • @PanagiotisKanavos : ohk. I can try downloading from https://www.visualstudio.com/vs/preview/. However, this available update never showed up any notification to update. – rahulaga-msft Apr 03 '18 at 12:16
  • 3
    Previews don't show up as updates. They have to be manually installed, and they run along-side any existing VS installations. In order to use 2.1, currently, you have to run the VS 2017 preview, both to create the project and work on it. – Chris Pratt Apr 03 '18 at 12:50
  • @ChrisPratt : Thx !! I installed vs2017 15.7 preview 2 (updated question) - but still same issue. – rahulaga-msft Apr 03 '18 at 13:51
  • I have VS 2017 15.7.4 and I still don't get the `Core 2.1` option. How about that? Maybe because my project was created with an older version of VS? – NoOne Jul 02 '18 at 14:12

9 Answers9

19

I have faced the same problem. I solved this by installing the right SDKs with Runtime for .NET Core 2.1.

Basically to run/create 2.1 projects from VS Preview, you need to install the "2.1.300" (not 2.1.4) .NET Core SDKs and Runtime. https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1 (this includes required Runtime already)

The good explanation of this misleading with versions i found here https://github.com/dotnet/cli/issues/8309 (dasMulli commented on Feb 24).

Deniss Kulakov
  • 220
  • 2
  • 6
10

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.

To create the global.json you can navigate to the desired folder and type this:

dotnet new globaljson

Will Tartak
  • 548
  • 7
  • 17
  • Thanks a lot for that, I've had exactly the same issue. Hopefully this is a bug in VS. – Vidmantas Blazevicius Nov 28 '18 at 21:11
  • FWIW, I think this is an intended change in behavior so that new projects use the latest release bits instead of any installed previews. That way you have to intentionally opt in to the preview stuff. Just my take. – Will Tartak Nov 30 '18 at 22:37
  • My previous comment was correct. Confirmation at https://blogs.msdn.microsoft.com/dotnet/2018/11/13/net-core-tooling-update-for-visual-studio-2017-version-15-9/ – Will Tartak Dec 03 '18 at 21:24
  • Ok cool, that actually makes sense when I think about it. Thanks for the letting us know. – Vidmantas Blazevicius Dec 04 '18 at 13:27
8

Make sure dotnet PATH variables are in correct order

If you have installed an SDK for a different system architecture (e.g., if you installed 32-bit/x86 SDK on a 64-bit computer), then a new entry in the PATH variable would have been created for that specific location (e.g., C:\Program Files\dotnet or C:\Program Files (x86)\dotnet).

The problem is that Visual Studio, when searching for installed frameworks, will stop at the first PATH variable entry it finds that contains an SDK. So, if the first version you installed used an incorrect architecture, then you'll have to adjust the position of those entries before any of the correct SDKs will appear in the Target Framework drop down.

Source: this absurdly-hard-to-find comment within issue #8309.


TL;DR: Make sure the first "C:\Program Files\dotnet\" entry in your path variable you see in the list matches your system architecture:

  • 64-bit = C:\Program Files\dotnet\
  • 32-bit = C:\Program Files (x86)\dotnet\
Ross Brasseaux
  • 3,879
  • 1
  • 28
  • 48
  • 2
    After countless hours of head scratching this proved to be the root cause. – Raj Mar 02 '20 at 22:18
  • In my case I had foolishly assumed my build server was x64 without checking. After updating the path variable I then also had to install the x86 versions of the .NET Framework. – MoonBoots89 May 27 '20 at 10:49
3

Make sure that Visual Studio 2017 is up to date. Go to "Tools" -> "Extensions and Updates" to install visual studio updates. This resolved the issue for me.

Aqua Cat
  • 41
  • 3
1

I have faced the similar situation I tried to install the preview version of the dot net but it did not help. However after I updated visual studio (from 15.8 to 15.9.6 ). I Could see dot net core 2.1 in the target framework.

1

Updated to Latest VS 2017 and installed latest .Net Core SDK. Changed global.json to point to latest version installed. This resolved for me.

Dharmesh Tailor
  • 320
  • 1
  • 11
0

I had faced the similar issue. I then just updated my Visual Studio 2017 to 15.9.16 version and restarted the system. The problem got resolved.

kanika
  • 92
  • 1
  • 13
0

I was facing the similar issue, I uninstalled the .Net Core 2.2 runtime and then from the below link:

https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral

Install the .Net Core 2.2 Visual Studio SDK, Restarted the Visual Studio and my issue got resolved, .Net Core 2.2 is now getting listed in Target Framework list in the project properties in Visual Studio 2017 Version 15.9.16

Ambuj
  • 433
  • 5
  • 10
0

I created a new project under .net core 2.1 and it was ok but in my old project have not appeared. So I opened both ".cproject" files and compared them together and found the problem.
Open your project's ".cproject" file in a text editor then replace below line

<TargetFramework>netstandard2.1</TargetFramework>

with this one:

<TargetFramework>netcoreapp2.1</TargetFramework>
Ramin
  • 134
  • 6