构建我的.NET Web应用程序时出现奇怪的.NET程序集警告

时间:2017-04-25 04:02:58

标签: c# asp.net .net assemblybinding

当我构建我的ASP.NET Web应用程序时,我在构建输出中看到以下奇怪的警告。

1>------ Build started: Project: Hornet.Api, Configuration: Debug Any CPU ------
1>  No way to resolve conflict between "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
1>  No way to resolve conflict between "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
1>  Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "9.0.0.0" [] to Version "10.0.0.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "Microsoft.ApplicationInsights, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "2.2.0.0" [] to Version "2.3.0.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\Microsoft.ApplicationInsights.2.3.0\lib\net46\Microsoft.ApplicationInsights.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Text.RegularExpressions, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.10.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Text.RegularExpressions.dll] to Version "4.1.0.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Net.Http.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Net.Http.4.3.1\lib\net46\System.Net.Http.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Diagnostics.Tracing, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.20.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Diagnostics.Tracing.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Reflection, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.10.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Reflection.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Runtime, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.20.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Runtime.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.IO.Compression, Culture=neutral, PublicKeyToken=b77a5c561934e089" from Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.IO.Compression.dll] to Version "4.1.2.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Runtime.Extensions, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.10.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Runtime.Extensions.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "Microsoft.Azure.KeyVault.Core, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "2.0.0.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\Microsoft.Azure.KeyVault.Core.2.0.4\lib\net45\Microsoft.Azure.KeyVault.Core.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Runtime.InteropServices, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.20.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Runtime.InteropServices.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll] to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Linq, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Linq.dll] to Version "4.1.1.0" [C:\Projects\Personal\Hornet\Hornet.Api\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll] to solve conflict and get rid of warning.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /><bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Microsoft.ApplicationInsights" culture="neutral" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-2.3.0.0" newVersion="2.3.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Text.RegularExpressions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Diagnostics.Tracing" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Reflection" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.IO.Compression" culture="neutral" publicKeyToken="b77a5c561934e089" /><bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime.Extensions" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Microsoft.Azure.KeyVault.Core" culture="neutral" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime.InteropServices" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Linq" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /></dependentAssembly></assemblyBinding>

我的解决方案有两个项目:

  • 网站(ASP.NET v4.7)
  • 测试(.NET v4.7)

所以我不确定这些警告适用于哪个项目? -

此外,我已检查web.config的(网站项目)app.config和(测试项目)AssemblyBindings,他们都指向最新的...这是在两个文件中:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>

 .....

那么为什么编译器认为与各种版本的Newtonsoft.Json存在冲突?我只安装了一个版本......

我也有组装装置,他们似乎都指向安装的最新版本。

更新

  • 这是我的packages.config
  • 的摘要

<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net47" />

两个项目中的那个,顺便说一句

这...... enter image description here

更新2

这里的hintpath对于两个项目都是相同的......

<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

更新3

好的 - 这很有趣。

  • 启用VERBOSE构建信息
  • 我现在可以看到更多数据。第一个警告是说我的nuget package Google.Apis.QpxExpress.v1最终依赖于Google.Apis.Core,它依赖于Json v 9.0.0。
  • 我的web.config文件绑定重定向! (见上文)。

0 个答案:

没有答案