奇怪的 NU1605 引用 NETStandard.Library 1.6.0,而导流点的库实际上引用的是 netstandard 版本 2.0

Bizarre NU1605 referecing NETStandard.Library 1.6.0 when the library of the diversion point is actually referencing netstandard version 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 缓存已损坏。