如何解决奇怪的 NU1605 引用 NETStandard.Library 1.6.0,而分流点的库实际上引用了 netstandard 版本 2.0
.NET 5 项目在我的工作站上正确构建,但在构建服务器上却崩溃了。这个问题在将 .NET Core 3.1 升级到 .NET 5 时立即出现,这恰逢在构建服务器上安装 .NET 5。
来自构建服务器的错误:
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Console 4.0.0 -> runtime.win.System.Console 4.3.0 -> System.IO.FileSystem.Primitives (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem.Primitives (>= 4.0.1)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.Text.Encoding.Extensions from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Diagnostics.Debug (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Diagnostics.Debug (>= 4.0.11)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.IO.FileSystem.Primitives (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem.Primitives (>= 4.0.1)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.Text.Encoding.Extensions from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Text.Encoding.Extensions (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Text.Encoding.Extensions (>= 4.0.11)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Net.sockets 4.1.0 -> runtime.win.System.Net.sockets 4.3.0 -> System.Diagnostics.Debug (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Diagnostics.Debug (>= 4.0.11)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Net.sockets 4.1.0 -> runtime.win.System.Net.sockets 4.3.0 -> System.IO.FileSystem (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem (>= 4.0.1)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.Net.sockets 4.1.0 -> runtime.win.System.Net.sockets 4.3.0 -> System.IO.FileSystem.Primitives (>= 4.3.0)
Centoscript.Forms\Cedaron.Centoscript.Forms.csproj : error NU1605: Centoscript.Forms -> CentoScript 5.2.0.3 -> NETStandard.Library 1.6.0 -> System.IO.FileSystem.Primitives (>= 4.0.1)
Centoscript.Forms
的项目文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Include="../AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<packagereference Include="Common" Version="2.2.0" />
<packagereference Include="CentoScript" Version="5.2.0.3" />
</ItemGroup>
</Project>
Centoscript 的项目文件(在工作和损坏之间保持不变——它针对 netstandard2.0 以便在核心和框架之间交叉使用):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>CentoScript</AssemblyName>
<PackageId>CentoScript</PackageId>
<Version>5.2.0.4</Version>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<packagereference Include="Common" Version="1.0.2" />
</ItemGroup>
<ItemGroup>
<packagereference Include="System.Dynamic.Runtime" Version="4.0.11" />
<packagereference Include="System.Net.Primitives" Version="4.3.0" />
<packagereference Include="Microsoft.CSharp" Version="4.0.1" />
<packagereference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>
</Project>
我怀疑我们通过 Common
得到了错误的引用,除了 CentoScript.Forms
使用更高版本的 Common
应该会踩踏引用。无论如何,这是一种糟糕的解释,因为它一直在工作,直到 CentoScript.Forms
的构建目标从 netcoreapp3.1
更改为 net5.0
。
我不应该添加对列出的包的引用,我绝对不应该在任何请求的版本中添加它们。 net5.0 应该会自动选择它们的更高版本。
是的,我确实想放置两个不同的 .NET 版本标签。显然有多个版本在起作用。
解决方法
糟糕,问题是构建服务器上的 nuget 缓存损坏。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。