How to suppress 'Found conflicts between diffe

2019-08-06 13:52发布

问题:

In a project I have the following reference layout:

References
+- AssemblyA 6.7.6643.0
+- AssemblyB
|  \- AssemblyA 7.0.0.0
\- AssemblyC
   \- AssemblyA 7.0.0.0

AssemblyB and AssemblyC are NuGet references for which there is no downgrade. Due to circumstances outside of my control, upgrading AssemblyA is not an option. But I get this warning:

Found conflicts between different versions of "AssemblyA" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

So I did just that and this is the output:

There was a conflict between "AssemblyA, Version=6.7.6643.0" and "AssemblyA, Version=7.0.0.0". "AssemblyA, Version=6.7.6643.0" was chosen because it was primary and "AssemblyA, Version=7.0.0.0" was not. References which depend on "AssemblyA, Version=6.7.6643.0" [AssemblyA.dll]. AssemblyA.dll Project file item includes which caused reference "AssemblyA.dll". AssemblyA, Version=6.7.6643.0 References which depend on "AssemblyA, Version=7.0.0.0" []. AssemblyB.dll Project file item includes which caused reference "AssemblyB.dll". AssemblyB, Version=7.0.0.0 AssemblyC.dll Project file item includes which caused reference "AssemblyC.dll". AssemblyC, Version=9.0.0.0

It chose the version I wanted it to, but I still get a warning in Visual Studio. So I updated the app.config binding redirect in the hopes it would get rid of the warning:

<dependentAssembly>
  <assemblyIdentity name="AssemblyA" publicKeyToken="..." culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="6.7.6643.0" />
</dependentAssembly>

But the warning persists. I have confirmed that if I upgrade AssemblyA to 7.0.0.0 it causes the warning to go away. But as I said earlier, for other reasons outside of my control I cannot upgrade this assembly right now.

Is there anyway to suppress this warning just for this one particular instance?

Thanks

回答1:

1.This warning seems to occur when the compiler compile the project, it will be confused about which version of the .dll to use so that it throws the MSB3277 warning. Usually, we can solve this warning by upgrading your old version or downgrading new version. But in this situation, it seems no valid way to resolve this warning.

2.What’s more, sometimes we can suppress the warning by setting some property, but that seems not work for MSB warnings because Warnings with MSB prefix are thrown by MSBuild and there has no valid way to suppress MSB warning currently.

Especially for MSB3277, I test with vs2017 by nowarn, #pargma, property in proj but unfortunately,it do not work. We can find similar issues here: How to suppress specific MSBuild warning Suppress MSB4126

So, I am afraid we have no valid way to suppress MSB3277 currently. Sorry about this inconvenience.