System.Net.Http 4.2 与 .NET 4.7

System.Net.Http 4.2 with .NET 4.7

如何消除构建输出中的警告?

解决方案中的所有项目都以 .NET Framework 4.7 为目标。 这是一个巨大的解决方案,包含 50 多个我不熟悉的项目。 不确定是什么更改导致了这些警告,可能是添加了 System.Web.Http.SelfHost.dll 程序集。 无论程序集重定向绑定如何,构建输出都会溢出。 另外,我正在使用 Visual Studio 2019(看起来像源 dll 供参考 System.Net.Http v4.2)。

(ResolveAssemblyReferences target) -> 
Found conflicts between different versions of "System.Net.Http" that could not be resolved.
There was a conflict between "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
     "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
  References which depend on "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Net.Http.dll].
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Net.Http.dll
  References which depend on "System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\dev\Build\System.Net.Http.dll].
    C:\dev\Build\CommonLib.dll
    C:\dev\Build\AnotherLib.dll
    C:\dev\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll
    C:\dev\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll
    C:\dev\Build\System.Web.Http.SelfHost.dll
    C:\dev\Build\netstandard.dll

在我尝试 之后,在构建输出中添加了其他引用,例如:

Org.Lib.Workflow, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
System.Web.Http.SelfHost, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL

也尝试了投票最高的版本 (newVersion="4.0.0.0"),但没有任何改变

根据建议,由于我需要使用 4.2 版,我已将相应的版本复制到存储库并添加了对它的引用。