由于有两个NuGet,“无法解决冲突”

问题描述

从packages.config迁移到packagereference后,我的构建在构建计算机上失败。在我的开发机器上它可以编译! (两个VS版本均为15.9.27,BuildTools仅在Buildmachine上,Professional在我的计算机上) 框架:4.6.1

在编译机上的编译器输出

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3243: No way to resolve conflict between "System.Windows.Interactivity,Version=4.5.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" and "System.Windows.Interactivity,Version=4.0.0.0,PublicKeyToken=31bf3856ad364e35". Choosing "System.Windows.Interactivity,PublicKeyToken=31bf3856ad364e35" arbitrarily. [path_to_project\project.csproj]
  Consider app.config remapping of assembly "System.Windows.Interactivity,PublicKeyToken=31bf3856ad364e35" from Version "4.0.0.0" [C:\Users\user\.nuget\packages\system.windows.interactivity.wpf\2.0.20525\lib\net40\System.Windows.Interactivity.dll] to Version "4.5.0.0" [C:\Users\user\.nuget\packages\mvvmlightlibs\5.4.1\lib\net45\System.Windows.Interactivity.dll] to solve conflict and get rid of warning.
... cut ...
Build Failed.

"path_to_project\project.csproj" (rebuild target) (1) ->
(ResolveAssemblyReferences target) -> 
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,PublicKeyToken=31bf3856ad364e35" arbitrarily. [path_to_project\project.csproj]


"path_to_project\project.csproj" (rebuild target) (1) ->
"path_to_project\project_sesfqpto_wpftmp.csproj" (_CompileTemporaryAssembly target) (3) ->
(CoreCompile target) -> 
  Behaviors\DecimalPointTextBox.cs(19,30): error CS0433: The type 'Behavior<T>' exists in both 'System.Windows.Interactivity,PublicKeyToken=31bf3856ad364e35' and 'System.Windows.Interactivity,PublicKeyToken=31bf3856ad364e35' [path_to_project\project_sesfqpto_wpftmp.csproj]
  Behaviors\DecimalPointTextBox.cs(21,27): error CS0115: 'DecimalPointTextBox.OnAttached()': no suitable method found to override [path_to_project\project_sesfqpto_wpftmp.csproj]

    1 Warning(s)
    2 Error(s)

通过详细信息进行的构建运行表明,通过NuGets MvvmLight和system.windows.interactivity.wpf(反过来又通过Simple.Wpf.Terminal间接包含)包含了多个System.Windows.Interactivity.dll:

C:\Users\user\.nuget\packages\mvvmlightlibs\5.4.1.1\lib\net45\System.Windows.Interactivity.dll
C:\Users\user\.nuget\packages\system.windows.interactivity.wpf\2.0.20525\lib\net40\System.Windows.Interactivity.dll

我已经将此添加到app.config,配置/运行时:

<dependentAssembly>
  <assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>

但没有帮助,对于将项目文件中的AutoGenerateBindingRedirects设置为true相同

Simple.Wpf.Terminal的较新版本不再依赖于system.windows.interactivity.wpf,而是需要框架4.8,不幸的是,当前这对我来说是没有选择的。 这两个System.Windows.Interactivity.dll都应该起作用,但是如何告诉他仅使用一个?不可能将这些NuGet结合起来吗?但是为什么要在我的机器上编译并运行它呢? NuGet真是个地狱...

在我工作的机器上,开始时的编译器输出看起来有些不同,并且提供了更多信息(正常的详细程度):

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.ConflictResolution.targets(33,5): message NETSDK1041: Encountered conflict between 'Reference:C:\Users\meyerrn\.nuget\packages\mvvmlightlibs\5.4.1\lib\net45\System.Windows.Interactivity.dll' and 'Reference:C:\Users\meyerrn\.nuget\packages\system.windows.interactivity.wpf\2.0.20525\lib\net40\System.Windows.Interactivity.dll'.  NETSDK1033: Choosing 'Reference:C:\Users\meyerrn\.nuget\packages\mvvmlightlibs\5.4.1\lib\net45\System.Windows.Interactivity.dll' because AssemblyVersion '4.5.0.0' is greater than '4.0.0.0'. [C:\Work.git\Main\EvoPro\Cockpit\Cockpit.csproj]

只需说明一下:在两台计算机上,输出都包含完全相同的版本:

MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...