简体   繁体   English

'在 Package 管理器控制台中找不到 Microsoft.NETCore.App 2.0.0

[英]'Microsoft.NETCore.App 2.0.0 not found in Package Manager Console

I recently upgraded my .NET projects from .NET 5.0 to .NET 6.0.我最近将我的 .NET 项目从 .NET 5.0 升级到 .NET 6.0。

When I attempt to add a migration in Package Manager Console, I get the following error.当我尝试在 Package 管理器控制台中添加迁移时,出现以下错误。

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:
      5.0.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      6.0.0 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

I'm confused by this.我对此感到困惑。 Why is it looking for version 2.0.0 of Microsoft.NETCore.App ?为什么要寻找Microsoft.NETCore.App的 2.0.0 版? Is that an older version?那是旧版本吗? And why would it be missing now that I've updated my projects to .NET 6.0?为什么现在我已经将我的项目更新为 .NET 6.0,它会丢失?

I looked in my project but don't see any reference to this package. Can anyone help me understand what is wrong?我查看了我的项目,但没有看到任何对此 package 的引用。任何人都可以帮助我了解哪里出了问题吗?

Update更新

Here is the project file for my main application.这是我的主要应用程序的项目文件。

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\TTRailtraxBusinessLayer\TTRailtraxBusinessLayer.csproj" />
    <ProjectReference Include="..\TTRailtraxEntities\TTRailtraxEntities.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Attributes\" />
  </ItemGroup>

</Project>

And here is the project file for the library project that contains my entities.这是包含我的实体的库项目的项目文件。

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\RailtraxCore\RailtraxCore.csproj" />
  </ItemGroup>

</Project>

As you can see, there are other library projects being used as well.如您所见,还使用了其他库项目。

Well, Entity Framework's tooling for Powershell has a semantic to pass parameters into EF tools.好吧,Entity Framework 的 Powershell 工具具有将参数传递到 EF 工具的语义。 It passes both the default project and the startup project but for multiple startup projects, it uses the default project as a fallback project.它同时传递默认项目和启动项目,但对于多个启动项目,它使用默认项目作为后备项目。 EF tools requires a configured DbContext (associated with a provider and connection string) this is the startup project that consumes the DbContext and configures it. EF 工具需要一个已配置的 DbContext(与提供程序和连接字符串相关联),这是使用 DbContext 并对其进行配置的启动项目。 And a migration assembly that locates the migrations and that is usually the project that contains DbContext.以及一个定位迁移的迁移程序集,通常是包含 DbContext 的项目。 So generally when I add migrations with PMC I set the startup project to an application and set the default project in PMC to the DbContext project.因此,通常当我使用 PMC 添加迁移时,我将启动项目设置为应用程序,并将 PMC 中的默认项目设置为 DbContext 项目。

Here is the Powershell module if you want to dig deeper.如果您想深入挖掘, 这里是 Powershell 模块。

Try changing project framework to the ones that are found ie 3.1 or 5.0: Right click on project -> Properties -> Application -> Target framework尝试将项目框架更改为找到的框架,即 3.1 或 5.0:右键单击项目 -> 属性 -> 应用程序 -> 目标框架在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .Net Core Classlib 错误地要求 Microsoft.NETCore.App 2.0.0 - .Net Core Classlib misrequires Microsoft.NETCore.App 2.0.0 检测到 package 降级:Microsoft.NETCore.App 从 2.1.3 到 2.1.0 - Detected package downgrade: Microsoft.NETCore.App from 2.1.3 to 2.1.0 如何修复“Microsoft.NETCore.App”,找不到版本“1.1.2”? - How to fix 'Microsoft.NETCore.App', version '1.1.2' was not found? 未找到指定的框架“Microsoft.NETCore.App”,版本“2.1” - The specified framework 'Microsoft.NETCore.App', version '2.1' was not found 找不到框架“Microsoft.NETCore.App”,版本“5.0.13” - The framework 'Microsoft.NETCore.App', version '5.0.13' was not found 未找到 Microsoft.NetCore.App 或 Microsoft.AspNetCore.App 的指定版本 - The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found 找不到指定版本的 Microsoft.NetCore.App 或 Microsoft.AspNetCore.App。 .net 6.0升级 - The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found. .net 6.0 upgrade NETStandard.Library package 和 Microsoft.NETCore.App 包有什么区别? - What’s the difference between NETStandard.Library package and Microsoft.NETCore.App packages? ASP.NET Core 3.1 Web 应用程序失败,出现“Microsoft.NETCore.App”,找不到版本“3.1.27”错误 - ASP.NET Core 3.1 Web application failed with 'Microsoft.NETCore.App', version '3.1.27' was not found error Mac - 找不到框架“Microsoft.NETCore.App”,版本“3.1.0”(x64) - Mac - The framework 'Microsoft.NETCore.App', version '3.1.0' (x64) was not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM