Corefxlab: Can't run .NET Core app in VS

Created on 27 Apr 2018  路  5Comments  路  Source: dotnet/corefxlab

I'm trying to run the sample apps in VS, but it tells me that the specified framework was not found.

As an example, if I run

D:\Repos\corefxlab\samples>..\dotnetcli\dotnet.exe LowAllocationWebServer\bin\Debug\netcoreapp2.1\LowAllocationWebServer.dll

the server starts up. But if I go to VS and make LowAllocationWebServer the startup project and run it with Ctrl-F5, I get the error message:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.2.0-preview1-26424-02' was not found.
  # clipped for brevity
  - The following versions are installed:
      # clipped for brevity
      2.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.0-preview1-26216-03 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.0-preview2-26406-04 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

I checked the dotnet.exe info, in the dotnetcli directory, and I can see it there

D:\Repos\corefxlab>dotnetcli\dotnet.exe --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.300-rc1-008662
 Commit:    6ae1926fb0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   D:\Repos\corefxlab\DotnetCLI\sdk\2.1.300-rc1-008662\

Host (useful for support):
  Version: 2.2.0-preview1-26424-02
  Commit:  286ba8868b

But if I check the dotnet.exe info outside of the dotnetcli directory, I do see that the two previews listed in the error, exist here

D:\Repos\corefxlab\samples>dotnet.exe --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.300-preview2-008533
 Commit:    996eb6c92c

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-008533\

Host (useful for support):
  Version: 2.1.0-preview2-26406-04
  Commit:  6833f3026b

# clipped for brevity

.NET Core runtimes installed:
  # clipped for brevity
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-preview1-26216-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-preview2-26406-04 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

So it seems like VS is using the wrong dotnet.exe executable.

Tested in VS 2017 15.6.4 and Preview 15.7.0 Preview 3.0

How do I fix this?

question or comment

All 5 comments

I believe this is the same issue you reported earlier. Hopefully, my comment here will help resolve it: https://github.com/dotnet/corefxlab/issues/2224#issuecomment-382944289

VS prefers to use the dotnet install available from the Program Files directory rather than the dotnetcli directory at the repo root. You can change that by adjusting your environment variables.

Setting the path fixed the issue. So this seems like an issue that anyone who has ever installed dotnet.exe, normally, would encounter, right? (At least those who try to run a sample/app.) Should this be added to the wiki?

Hopefully, we can make this easier for the next developer. :)

Setting the path fixed the issue. So this seems like an issue that anyone who has ever installed dotnet.exe, normally, would encounter, right? (At least those who try to run a sample/app.) Should this be added to the wiki?

Yes, anyone can encounter this (outside of corefxlab). Adding it to the README would help.

It is by design (based on how the cli works). Here are some related links and issues:

Updated wiki

@MisinformedDNA, can you please also update the README.md, here: https://github.com/dotnet/corefxlab#building-and-testing?

Was this page helpful?
0 / 5 - 0 ratings