Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The specified framework 'Microsoft.NETCore.App', version '2.0' was not found #8826

Closed
redowl3 opened this issue Oct 25, 2017 · 79 comments
Closed
Assignees
Labels
Milestone

Comments

@redowl3
Copy link

redowl3 commented Oct 25, 2017

Not sure if this is a cli issue or VS so happy to move to another area if not correct

Steps to reproduce

Update to Visual Studio Professional Preview (v 15.5.0 Preview 2)

Try to add data migration (using IDesignTimeDbContextFactory)

dotnet ef migrations add [MigrationName]

Expected behavior

Migration created

Actual behavior

Error message

The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.

  • Check application dependencies and target a framework version installed at:
    \
  • Alternatively, install the framework version '2.0'.

Environment data

Product Information:
Version: 2.1.1-preview-007094
Commit SHA-1 hash: f657648

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.1-preview-007094\

Microsoft .NET Core Shared Framework Host

Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

@livarcocc
Copy link
Contributor

Can you share your project or a repro of this issue?

@redowl3
Copy link
Author

redowl3 commented Oct 26, 2017

Hi,

Thanks for getting back to me.

The project is pretty big so not practical to share, but since updating to 15.5.0 Preview 2.0, as well as not being able to create migrations due to what looks like core versioning issues, I can no longer publish anything to Azure as the build fails although it builds fine in VS?

Whatever was changed with 15.5.0 Preview 2.0 looks to be creating a few issues.

As the issue appears to be with a project built with the previous version of the Preview, then updating to 15.5.0 Preview 2.0 I'm now unable to repro.

@livarcocc
Copy link
Contributor

You can add a global.json pinning your SDK version to version 2.0.2 (the last release we did with VS 15.4) or 2.0.0.

Just add the global.json file to the root of your repo with contents like this:

{
  "sdk": {
    "version": "2.0.2"
  }
}

This should unblock you. But notice that your SDK will be pinned to whatever version you put there. Let us know if this unblocks you.

It would also be super helpful if you could at least find a minimal repro for this problem. Is this happening on multiple machines?
Can you tell us what are the folders you have under C:\Program Files\dotnet\shared\microsoft.netcore.app? This will tell us which runtimes you have in the box.

@redowl3
Copy link
Author

redowl3 commented Oct 26, 2017

Thanks for the suggestion, I'll try that. I've only tried this on a single machine.

Folder structure below.
folder

@livarcocc
Copy link
Contributor

Could you share the contents of runtimeconfig.json file for your tool? And are you packaging it in your tool nupkg?

@netbidev
Copy link

Hello everyone. I have this problem too.

@livarcocc
Copy link
Contributor

@netbidev any chance you have a small repro for us?

@netbidev
Copy link

netbidev commented Oct 28, 2017

@livarcocc here
TestDB.DBModel.zip

The command here
dotnet ef dbcontext scaffold "Server=.;Database=TestDB;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer

@dls314
Copy link

dls314 commented Oct 30, 2017

@netbidev That project replicates the error for me as well

@dls314
Copy link

dls314 commented Oct 30, 2017

@livarcocc The workaround of adding a global.json file specifying 2.0.2 works for me.

Does anyone know if/how the --fx-version argument could be used instead? global.json is tacky.

@livarcocc
Copy link
Contributor

the --fx-version argument is a host argument that can be used to indicate which runtime framework to use when running an application.

Like this: dotnet --fx-version 2.0.0 <app.dll>.

@dls314
Copy link

dls314 commented Oct 30, 2017

I guess that the dotnet ef command can't be used with host arguments? I've tried putting --fx-version in various places in a command like dotnet ef migrations list without success.

@jeremymeng
Copy link
Member

jeremymeng commented Nov 9, 2017

Hit this issue in an xunit test project too. Repro:

  1. dotnet new xunit
  2. Upgrade to latest xunit 2.3.1, and add dotnet-xunit tool
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170810-02" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
  </ItemGroup>
  1. dotnet build
  2. dotnet xunit

Actual:

Detecting target frameworks in test2.csproj...
Building for framework netcoreapp2.0...
  test2 -> e:\temp\test2\bin\Debug\netcoreapp2.0\test2.dll
Running .NET Core 2.0 tests for framework netcoreapp2.0...
The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
  - Check application dependencies and target a framework version installed at:
      \
  - Alternatively, install the framework version '2.0'.

Notes:
dotnet test works.
dotnet xunit --fx-version 2.0.0 works too.

@Kurtbaby
Copy link

Kurtbaby commented Nov 15, 2017

I am having the same issue after upgrading to v15.4.4. The only solution I've found so far to fix the CLI tools issue it to add the RuntimeFrameworkVersion inside the property group as such:

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
</PropertyGroup>

@livarcocc
Copy link
Contributor

I can't repro this using SDK 2.1.1-preview-007139 on a Mac or 2.1.1-preview-007165 on Windows. For those that are reproing this, is it always reproing on Windows? If so, can you make sure that you don't have two different dotnet versions installed, one x86 and one x64? And that the one being used by the tool is not being the wrong one? I mean, make sure that the right dotnet installation is coming before the other one in the path environment variable.

@livarcocc livarcocc self-assigned this Nov 15, 2017
@jeremymeng
Copy link
Member

jeremymeng commented Nov 15, 2017

I found that I had some preview versions of dotnet sdk installed, including 2.0.3. The latest on dot.net seems 2.0.2. After uninstalling those and only keeping 2.0.0, 2.0.2, and 2.1.1-preview-007118, the issue no longer reproduces for me

@haidelber
Copy link

I'm having the same issue ever since I upgraded to Visual Studio 15.4.4 which obviously included the sdk 2.0.3

@jorgeyanesdiez
Copy link

Same issue here as @jeremymeng
I have cleaned up my system, and only have the 2.0.3 SDK, runtime (x64 and x86) and windows server hosting packs, therefore, @livarcocc 's solution doesn't work for me, but @Kurtbaby 's does.

@Kurtbaby
Copy link

Microsoft recognized some of the errors of their ways and released new versions of the runtime and server hosting for 2.0.3 since my last post, and this has solved our deployment issue (not discussed this thread), but sadly, we still have to use the RunTImeFrameworkVersion tag in the project in order to use dotnet ef ... commands. We are also using a "Data project" and have isolated the context, etc. into this class lib, which uses a DesignTimeFactory for the context. I have not yet tested this behavior against a standard, template-generated web project, but will do so and report the results back here.

@Kurtbaby
Copy link

Here's an update. If we leave the context and models in the same aspnet web core project generated by the template, we are able to run the CLI tools without the error. As soon as we extract the context and models into their own class lib, we are forced to use the RunTimeFrameworkVersion tag in order to use the CLI tools. Not sure why as this class lib code/technique was working fine until we upgraded to v15.4.4.

@livarcocc
Copy link
Contributor

@Kurtbaby any chance you can provide a repro project? On github or a zip? I would love to debug this issue.

@livarcocc
Copy link
Contributor

We have gotten a repro for this issue and understand it now. We are working on a fix for it. The best work around available to it right now is setting RuntimeFrameworkVersion in your library project targeting netcoreapp2.0. I will explain why this happens in a next comment when I get a chance.

@livarcocc
Copy link
Contributor

So, the issue here is that the SDK was setting the implicit version of the Microsoft.NETCore.App to 2.0 instead of 2.0.0. NuGet was then restoring using that and finding the closest available package. We then used that version to write the rutimeconfig.json file.

In the cases where this repros, the libraries target netcoreapp2.0, but because they are libraries, no runtimeconfig.json is generated and EF ends up evaluating the RuntimeFrameworkVersion from the project and sees it as 2.0, which the host then does not understand, which leads to the failure here.

This works for apps because in that case we do generate a runtimeconfig.json and use that to run EF.

The real fix here is really just changing the implicit version from 2.0 to 2.0.0.

@jorgeyanesdiez
Copy link

@livarcocc can that be done without waiting for fixed packages? eg: using global.json?

@nathannis
Copy link

nathannis commented Nov 16, 2017

I have this issue as well after upgrading to VS 15.4.4
dotnet --version is printing as 2.0.3

The property group fix by @Kurtbaby fixes it for me as well.

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
</PropertyGroup>

I am adding it before running dotnet ef migrations add ... and then removing it before committing to source control since this seems like a bug that will be fixed soon.
Thanks!

@bricelam
Copy link
Contributor

bricelam commented Nov 16, 2017

Workaround (EF Tools)

Adding the following to the project should also make it work.

<PropertyGroup>
  <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

@bgrainger
Copy link

<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> didn't fix the problem for me with xunit (e.g., as in this comment).

The <RuntimeFrameworkVersion> and --fx-version workarounds did; this isn't ideal because (I would assume) it now requires all contributors and CI environments to have exactly that SDK version installled.

@bricelam
Copy link
Contributor

Sorry, can't speak for xUnit.net... Updated.

@livarcocc
Copy link
Contributor

@bgrainger I would suggest filling an issue under xunit itself for this. They may have to do the same fix there that we are doing in EF. The fix that we can make on the SDK side won't really fix the problem for tools if they are using the --fx-version option of the host to specify a runtime.

@livarcocc
Copy link
Contributor

dotnet --version gives you the SDK version that is being resolved.

@DouglasMarsh
Copy link

DouglasMarsh commented Jan 31, 2018

The issue is closed but the bug seems to still exist.

I'm experiencing this issue with latest Visual Studio 2017 (15.5.6)
adding RuntimeFrameworkVersion to csproj does not fix the issue of dotnet test not discovering tests
colleagues that are using VS version 15.5.1 are not experiencing this issue.

note: dotnet xunit will discover and run tests after RuntimeFrameworkVersion is added

A sample project that repos this issue with just an xUnit and UnitTest project is attached.
vs2017_15.5.6_UnitTestIssues.zip


.NET Command Line Tools (2.1.4)

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

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
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

@Sotam
Copy link

Sotam commented Feb 4, 2018

Currently have 2.1.0-preview2-26131-06 installed, but VS2017 doesn't detect the framework. Do I need to install something else? Currently I can only select up to dotnet core 2.0.

@livarcocc
Copy link
Contributor

@mlorbetske for the template question.

@mlorbetske
Copy link
Contributor

@phenning I’m case he has any thoughts here.

@Sotam if you run “dotnet new console” at the command line, does a 2.1 project get created?

@Sotam
Copy link

Sotam commented Feb 4, 2018

@mlorbetske First I must apologize, replied to the wrong issue. But nonetheless, you made my day! I was able to create a new project using the console and then build it in VS2017 :)

@DiginessForever
Copy link

DiginessForever commented Feb 9, 2018

I'm having this problem as well. "dotnet --version" is 2.1.4. I am using Visual Studio Enterprise 2017.

@Sotam
Copy link

Sotam commented Feb 9, 2018

@DiginessForever which version do you have? (dotnet --info)

@DiginessForever
Copy link

2.1.4 (updated my comment above).

@Sotam
Copy link

Sotam commented Feb 9, 2018

@DiginessForever I'm running a preview build .NET Command Line Tools (2.1.300-preview1-008019) . If I remember correctly, gotten from here

@DiginessForever
Copy link

One of my issues is that I have my data layer in a separate project (all the layers, App, Domain, Repository, and Data are in separate projects). The data layer is a class library.

@redowl3
Copy link
Author

redowl3 commented Feb 9, 2018

Have you tried adding a global.json file to you data project?
{
"sdk": {
"version": "2.1.4"
}
}

@tiwilson7
Copy link

We had this same problem for developers who only had the "Microsoft .NET Core SDK - 2.1.x" installed but did not have a 2.0.x version of the SDK installed.

The solution (work-around, really) was to go the the archive downloads and install the latest 2.0.x SDK version (which can live side by side with 2.1.x).

.NET Core 2.0.3 SDK

riQQ referenced this issue in riQQ/SabberStone Feb 15, 2018
See dotnet/cli#7901
rnilva referenced this issue in HearthSim/SabberStone Feb 16, 2018
* Fix Gui project on travis

* Fix xUnit on travis

* Fix xUnit errors

* Use fixed runtime version

See dotnet/cli#7901
@rfuhrer
Copy link

rfuhrer commented Feb 16, 2018

@tiwilson7 Thanks for that. I just built a new machine (only has the latest SDK installed) and got everything up and running except xunit CLR. It doesn't work even with dotnet xunit -fxversion 2.1.4. After installing the 2.0.3 SDK and running dotnet xunit -fxversion 2.0.3 it was working again.

@jlanng
Copy link
Contributor

jlanng commented Feb 23, 2018

@rfuhrer did you find a solution? same problem here

@rfuhrer
Copy link

rfuhrer commented Feb 23, 2018

@jlanng install the old 2.0.3 SDK and then force it to run that sdk using the command dotnet xunit -fxversion 2.0.3. It's just your unit tests running that version so it's not like you're forcing your production copies to use an old version of dotnet core or anything.

I actually ended up not really using dotnet xunit since it didn't seem to play as nice with the dotnet CLI plugin for TeamCity (couldn't figure out how to make it know that it could run dotnet xunit and expect the results coming out to be digested the same way as dotnet test). Shaving a few seconds off my build time wasn't worth the hours i was going to spend trying to figure that out

@cgountanis
Copy link

cgountanis commented Mar 7, 2018

The global.json with 2.1.4 does not help when using dotnet ef commands in a classlib. You still have to manually add the RuntimeFrameworkVersion to the CSPROJ file on all projects in the solution. If you only add to one NUGET wants to consolidate because some projects are using 2.0.0 and only the ones specified with RuntimeFrameworkVersion use 2.0.5. I only have SDK 2.1.4 installed why does it just not use Runtime 2.0.5 by default?

<RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>

@jg11jg
Copy link

jg11jg commented Mar 13, 2018

Note that it is the Microsoft .NET Core Shared Framework Host framework version not the .NET Command Line Tools version that you need to use in the -fx argument (2.0.5 in the below, NOT 2.1.4)

`PS G:\MyFirstUnitTests> dotnet xunit
Detecting target frameworks in MyFirstUnitTests.csproj...
Building for framework netcoreapp2.0...
MyFirstUnitTests -> G:\MyFirstUnitTests\bin\Debug\netcoreapp2.0\MyFirstUnitTests.dll
Running .NET Core 2.0 tests for framework netcoreapp2.0...
The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.

  • Check application dependencies and target a framework version installed at:
    \
  • Alternatively, install the framework version '2.0'.
    PS G:\MyFirstUnitTests> dotnet --version
    2.1.4
    PS G:\MyFirstUnitTests> dotnet xunit -fxversion 2.1.4
    Detecting target frameworks in MyFirstUnitTests.csproj...
    Building for framework netcoreapp2.0...
    MyFirstUnitTests -> G:\MyFirstUnitTests\bin\Debug\netcoreapp2.0\MyFirstUnitTests.dll
    Running .NET Core 2.1.4 tests for framework netcoreapp2.0...
    It was not possible to find any compatible framework version
    The specified framework 'Microsoft.NETCore.App', version '2.1.4' was not found.
  • Check application dependencies and target a framework version installed at:
    \
  • Alternatively, install the framework version '2.1.4'.
    PS G:\MyFirstUnitTests> dotnet --info
    .NET Command Line Tools (2.1.4)

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

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

PS G:\MyFirstUnitTests> dotnet xunit -fxversion 2.0.5
Detecting target frameworks in MyFirstUnitTests.csproj...
Building for framework netcoreapp2.0...
MyFirstUnitTests -> G:\MyFirstUnitTests\bin\Debug\netcoreapp2.0\MyFirstUnitTests.dll
Running .NET Core 2.0.5 tests for framework netcoreapp2.0...
xUnit.net Console Runner (64-bit .NET Core 4.6.26020.03)
Discovering: MyFirstUnitTests
Discovered: MyFirstUnitTests
=== TEST EXECUTION SUMMARY ===
MyFirstUnitTests.dll Total: 0
PS G:\MyFirstUnitTests>`

@andreacassioli
Copy link

Any clear solution to this issue? I am running on OSX using dotnet from the CLI:

13:20 $ dotnet --version 2.1.4

`
13:20 $ dotnet xunit
Detecting target frameworks in PreplanningApiTests.csproj...
Building for framework netcoreapp2.0...
PreplanningApiTests -> /Users/aca286/workspace/deacon/preplanning-api/PreplanningApiTests/bin/Debug/netcoreapp2.0/PreplanningApiTests.dll
Running .NET Core 2.0 tests for framework netcoreapp2.0...
The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.

  • Check application dependencies and target a framework version installed at:
    /
  • Alternatively, install the framework version '2.0'.

`

I have tried some of the proposed workaround but no way.

@replaysMike
Copy link

I too have this issue. I think it was caused either when uninstalling preview-2 and installing preview-3. I no longer have a 2.1.0-preview2-final directory in C:\Program Files\dotnet only 2.1.0-preview1-26216-03 and launch using IIS Express anymore because of this issue.

@DiginessForever
Copy link

DiginessForever commented Apr 18, 2018 via email

@DiginessForever
Copy link

DiginessForever commented Jun 3, 2018 via email

@mistrykam
Copy link

mistrykam commented Jul 8, 2018

First determine which run time version you are using: dotnet --info

version

Then edit each .csproj and add the tag:

image

You will have to close and open Visual Studio.

@TheAifam5
Copy link

TheAifam5 commented Jul 17, 2018

Wow guys,
I have the newest version of dotnet and I still have this issue..... 👏
Just fresh projects and added Api as a reference to Tests. 👏 👏

dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

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

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.1.302 [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.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

dotnet xunit:

Detecting target frameworks in X.Tests.csproj...
Building for framework netcoreapp2.1...
  X.Api -> D:\Projects\Private Repositories\X.Api\bin\Debug\netcoreapp2.1\X.Api.dll
  X.Api.Tests -> D:\Projects\Private Repositories\X.Api.Tests\bin\Debug\netcoreapp2.1\X.Api.Tests.dll
Running .NET Core 2.1.0 tests for framework netcoreapp2.1...
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

@bloritsch
Copy link

NOTE: the XUnit libraries have another dependency runtime dependency that is not called out specifically: System.Text.Encoding.CodePages

I had to add that to my test project and use dotnet xunit -fxversion 2.1.2 to get Xunit to work.

@yatli
Copy link

yatli commented Nov 8, 2018

dotnet xunit is now deprecated:

xunit/xunit#1767

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 2.1.3xx milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests