sdk icon indicating copy to clipboard operation
sdk copied to clipboard

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

Open redowl3 opened this issue 9 years ago • 79 comments

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: f657648f07

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

redowl3 avatar Oct 25 '17 10:10 redowl3

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

livarcocc avatar Oct 25 '17 16:10 livarcocc

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.

redowl3 avatar Oct 26 '17 14:10 redowl3

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.

livarcocc avatar Oct 26 '17 16:10 livarcocc

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

Folder structure below. folder

redowl3 avatar Oct 26 '17 16:10 redowl3

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

livarcocc avatar Oct 26 '17 19:10 livarcocc

Hello everyone. I have this problem too.

netbidev avatar Oct 27 '17 16:10 netbidev

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

livarcocc avatar Oct 27 '17 16:10 livarcocc

@livarcocc here TestDB.DBModel.zip

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

netbidev avatar Oct 28 '17 04:10 netbidev

@netbidev That project replicates the error for me as well

dls314 avatar Oct 30 '17 16:10 dls314

@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.

dls314 avatar Oct 30 '17 16:10 dls314

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>.

livarcocc avatar Oct 30 '17 16:10 livarcocc

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.

dls314 avatar Oct 30 '17 17:10 dls314

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.

jeremymeng avatar Nov 09 '17 23:11 jeremymeng

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>

Kurtbaby avatar Nov 15 '17 20:11 Kurtbaby

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 avatar Nov 15 '17 21:11 livarcocc

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

jeremymeng avatar Nov 15 '17 22:11 jeremymeng

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

haidelber avatar Nov 16 '17 08:11 haidelber

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.

jorgeyanesdiez avatar Nov 16 '17 11:11 jorgeyanesdiez

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 avatar Nov 16 '17 15:11 Kurtbaby

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.

Kurtbaby avatar Nov 16 '17 16:11 Kurtbaby