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

Bundle-Migration "failed to restore project" or "it was not possible to find any compatible framework version" #27317

Open
StephanBis opened this issue Jan 31, 2022 · 10 comments
Labels
area-tools customer-reported propose-close punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug verify-fixed This issue is likely fixed in new query pipeline.
Milestone

Comments

@StephanBis
Copy link

We're trying to get the Bundle-Migration to work so we can integrate migrations in our CI/CD pipelines. We are however facing some issues.

When using the dotnet CLI, we're getting the following error

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
  - The following frameworks were found:
      3.1.22 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      6.0.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64

When using the Package Manager Console Bundle-Migration command

Failed to restore xxx.csproj (in 2,51 sec).
Failed to restore xxx.csproj (in 2,51 sec).
Restored xxx.csproj (in 2,51 sec).
Restored xxx.csproj (in 2,51 sec).
Restored xxx.csproj (in 2,51 sec).
Restored C:\Users\xxx\AppData\Local\Temp\zbp3cxwh.dds\efbundle.csproj (in 2,69 sec).
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args)
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)

We do not understand why the dotnet CLI is complaining about .NET Core 2.0.0 as we are not referencing any packages that require this framework.
On the other hand our projects restore and build just fine, no issues. So we also do not quite understand why ef-tools cannot restore some projects.

Versions:

  • VS2022 on Windows 11
  • All projects are .NET 6
  • NuGet packages are up-to-date (v6.0.1)
@StephanBis StephanBis changed the title Bundle-Migration "failed to restore project" or "tt was not possible to find any compatible framework version" Bundle-Migration "failed to restore project" or "it was not possible to find any compatible framework version" Jan 31, 2022
@ajcvickers
Copy link
Member

/cc @bricelam

@ajcvickers
Copy link
Member

Possible duplicate of #16882.

@StephanBis Can you post your csproj?

@krsnider
Copy link

krsnider commented Feb 2, 2022

Hello! Sorry to hijack, but my team has been running into this problem this week. This is our csproj.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RootNamespace>Redacted.Project.Data</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
    <PackageReference Include="Microsoft.Identity.Client" Version="4.29.0" />
  </ItemGroup>
  
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
  </ItemGroup>

</Project>

We have tried removing both the DotNetCliToolReference Item Group and the Microsoft.EntityFrameworkCore.Tools.DotNet PackageReference along with many other random attempts.

Note: Our startup project is a separate project, this project has a single DbContext which is the only DbContext in the solution

@ajcvickers
Copy link
Member

@krsnider This:

<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />

is an extremely old and obsolete package. It was replaced by the dotnet-ef before EF Core 2.1 shipped, but neither are intended to be referenced using PackageReference from a csproj.

Note for triage: the package is already listed as obsolete here: https://docs.microsoft.com/en-us/ef/core/what-is-new/nuget-packages

@StephanBis
Copy link
Author

Sorry for the late reaction.

Our database .csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
  </ItemGroup>
</Project>

Our startup project

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.5.1" />
    <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>
</Project>

As you can see we are not using the above mentioned Microsoft.EntityFrameworkCore.Tools.DotNet.

@AndriySvyryd
Copy link
Member

@bricelam cc

@bricelam
Copy link
Contributor

Related to #27385 (comment)?

@StephanBis
Copy link
Author

Any update on this? I see that this is added to the 7.0.0 milestone.

@ajcvickers
Copy link
Member

@StephanBis We don't yet understand what is going on here. The plan is to investigate and hopefully fix in 7.0 if we find the root cause. The workaround for now is to install .NET 2.x where needed.

@bricelam
Copy link
Contributor

This may have been fixed by PR #27671

@bricelam bricelam added the verify-fixed This issue is likely fixed in new query pipeline. label Mar 28, 2022
@ajcvickers ajcvickers added propose-punt punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. and removed propose-punt labels Jul 6, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Jul 7, 2022
@bricelam bricelam removed their assignment Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-tools customer-reported propose-close punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug verify-fixed This issue is likely fixed in new query pipeline.
Projects
None yet
Development

No branches or pull requests

5 participants