How to suppress 'Found conflicts between different versions of' warning?

岁酱吖の 提交于 2019-12-11 09:28:55

问题


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.



来源:https://stackoverflow.com/questions/54383985/how-to-suppress-found-conflicts-between-different-versions-of-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!