问题描述
我尝试将我的 .NET 解决方案从 .NET Core 1.1 更新到 .NET Core 2.1.我有几个 .NET Core 和 .NET 标准项目,它们相互引用并引用另一个 NuGet 包.更新 'dotnet resore' 和 'dotnet build' 命令后工作正常,但是当我尝试从 Visual Studio 构建我的解决方案时,我收到此错误:
I try to update my .net solution from .NET Core 1.1 to .NET Core 2.1. I have several .NET Core and .NET standard projects inside, which reference each other and another NuGet packages. After update 'dotnet resore' and 'dotnet build' commands work fine, but when i try to build my solution from visual studio, i get this error:
错误 NU1605 检测到包降级:Microsoft.NETCore.App 从 2.1.3 到 2.1.0.直接从项目中引用包以选择不同的版本.
Error NU1605 Detected package downgrade: Microsoft.NETCore.App from 2.1.3 to 2.1.0. Reference the package directly from the project to select a different version.
我发现我的一些项目确实有对 Microsoft.NETCore.App v2.1.0 的 SDK 引用,其中一些是 v.2.1.3.设置 RuntimeFrameworkVersion 并将此包显式添加到依赖项中不起作用.
And i see that indeed some of my projects have SDK reference to Microsoft.NETCore.App v2.1.0 and some of them v.2.1.3. Setting RuntimeFrameworkVersion and adding this package to dependencies explicitly doesn't work.
我该如何处理?
统一更新:dotnet --info:
UPD: dotnet --info:
.NET Core SDK (reflecting any global.json): Version: 2.1.401 Commit: 91b1c13032
Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:Program Filesdotnetsdk2.1.401
Host (useful for support): Version: 2.1.3 Commit: 124038c13e
.NET Core SDKs installed:
1.1.10 [C:Program Filesdotnetsdk]
2.0.0 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.100 [C:Program Filesdotnetsdk]
2.1.202 [C:Program Filesdotnetsdk]
2.1.400 [C:Program Filesdotnetsdk]
2.1.401 [C:Program Filesdotnetsdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App] Microsoft.NETCore.App
1.0.12 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App 1.1.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App
2.0.0 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App
2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App] Microsoft.NETCore.App
2.1.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
统一更新:如果我从 .csproj 文件中删除此行,问题就会以某种方式消失:
UPD: Somehow issue disappears if i remove this line from .csproj file:
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
可以关联吗?
推荐答案
我遇到了类似的问题.指定运行时标识符时无法发布我的项目.
I had a similar issue to you. Could not publish my project when I specified a runtime identifier.
我开始工作的解决方案是将以下行添加到 *.csproj
The solution I got to work was to add in the following line to the *.csproj
<PropertyGroup>
<TargetFramework> xxx </TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <<<----- Add this line
</PropertyGroup>
添加该行后,项目将正确发布.
After that line was added the project would publish correctly.
以下链接引用了 2.1.1 和 2.1.0 之间的降级问题,但解决方案效果相同.
The below link references a downgrade issue between 2.1.1 and 2.1.0 but the solution worked the same.
https://github.com/dotnet/cli/issues/9624
这篇关于检测到的包降级:Microsoft.NETCore.App 从 2.1.3 到 2.1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!