编译都OK,发布就报错,错误提示检测到程序包降级,排查发现都是来自于 BofSoft.Data 项目引用的包 MySql.Data
/* Error Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. BofSoft.Domain.Core -> BofSoft.Data -> MySql.Data 8.0.20 -> SSH.NET 2016.1.0 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Threading (>= 4.3.0) BofSoft.Domain.Core -> BofSoft.Data -> MySql.Data 8.0.20 -> SSH.NET 2016.1.0 -> System.Threading (>= 4.0.11) BofSoft.Web.OpenApi D:XYZBofSoftBofSoft.Domain.CoreBofSoft.Domain.Core.csproj */
在 BofSoft.Data 项目文件中指定所有出问题包的版本
<ItemGroup> <PackageReference Include="Dapper" Version="2.0.35" /> <PackageReference Include="MySql.Data" Version="8.0.20" /> <!-- 发布项目时出现如下错误: 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. 检测到包降级,原因是 MySql.Data 中引用的包版本与 .Net Core 3.1 中的不一致,因此在下面统一指定包的版本 --> <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.Globalization" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.Net.Primitives" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.Net.NameResolution" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.IO.FileSystem" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.Runtime.Extensions" Version="4.3.0" PrivateAssets="all" /> <PackageReference Include="System.Threading" Version="4.3.0" PrivateAssets="all" /> </ItemGroup>
再次发布成功