【发布时间】:2021-12-01 18:50:43
【问题描述】:
我最近将我的 .NET 项目从 .NET 5.0 升级到 .NET 6.0。
当我尝试在包管理器控制台中添加迁移时,我收到以下错误。
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
我对此感到困惑。为什么要寻找 Microsoft.NETCore.App 的 2.0.0 版本?那是旧版本吗?既然我已经将我的项目更新到 .NET 6.0,为什么它会丢失?
我查看了我的项目,但没有看到对这个包的任何引用。谁能帮我理解什么是错的?
更新
这是我的主应用程序的项目文件。
<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>
这是包含我的实体的库项目的项目文件。
<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>
如您所见,还有其他库项目也在使用中。
【问题讨论】:
-
在旧版本中它是一个单独的 Nuget 包。您可以更新项目 SDK 版本,但此包仍可能位于您的
.csproj文件中。您应该删除它,因为较新的版本不需要它。 -
@Eldar:嗯,这当然是有用的信息。但正如问题中提到的,我没有看到对这个包的任何引用。
-
你能分享你的
csproj文件内容吗? -
现在不推荐使用 .NET 2.0 SDK,Visual Studio 会警告您在安装时将其删除。
-
我的意思是,在包管理器控制台中,标题
Default Project: a dropdown here中有一个部分显示了所选项目。
标签: c# .net visual-studio .net-6.0