Freigeben über


Build warning msb3247 and msb3276 and msb3277

Frequently we may meet build warnings if a project indirectly reference same assembly with different versions. Recently I just noticed that such conflict version assembly may cause three similar/different build warnings: msb3247, msb3276 and msb3277. The error messages are very similar, all contains words like "Found conflicts between different versions of the same dependent assembly". However, the solution to resolve the build warnings are quite different.

When meet such warning, the first thing is to identify which assembly has conflicts. To do that, you just need to add a property in msbuild, e.g. "msbuild /fileLoggerParameters:LogFile=MyLog.log;Verbosity=detailed". The detailed build logs would be written to the file, which contains a log like "There was a conflict between "<assembly>, Version=<version1>" and "<assembly>, Version=<version2>"." to tell you the conflict assembly.

For msb3276, I can repro the build warning in Visual Studio 2013. You could add an assembly binding "<bindingRedirect oldVersion="0.0.0.0 - 2.0.0.0" newVersion="2.0.0.0"/>" in app.config/web.config to resolve the warning. Refer to https://msdn.microsoft.com/en-us/library/eftw1fys(v=vs.110).aspx. Or set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see https://go.microsoft.com/fwlink/?LinkId=294190. This warning can be reproed with the following dependencies trees:

           Assembly C V1.0.0.0

                      |

                 Project B                  Assembly C V2.0.0.0

                      |                               |

                      Executable Project A

 

For msb3277, I can repro the build warning in Visual Studio 2013. I found two kinds of situations could cause this warning. One case can be resolved by assembly binding, but the second one cannot.

(1)  The first case can be resolved by adding an assembly binding "<bindingRedirect oldVersion="0.0.0.0 - 2.0.0.0" newVersion="1.0.0.0" />", but cannot be resolved by setting the "AutoGenerateBindingRedirects" property. This case can be reproed with the following dependencies trees:

           Assembly C V2.0.0.0

                      |

                 Project B                  Assembly C V1.0.0.0

                      |                               |

                     Executable Project A

 (2) For the second case, it seems no easy way to resolve the warning but to use the same version of assembly instead. This case can be reproed with the following dependencies trees:

Assembly C V2.0.0.0 

              |

Assembly D           Assembly C V1.0.0.0

                |               |

                 Project B                  Assembly C V1.0.0.0

                      |                               |

                      Executable Project A

 

For msb3247, I can repro the build warning in Visual Studio 2012 <lower version may also repro>. The above three kinds of dependencies trees would cause the same warning msb3247 in VS2012, so such warning code cannot tell you whether you can resolve it with assembly binding. However, there is a difference that if the warning messages contain a hint like "Consider app.config remapping of assembly... ", it is like the msb3276 in VS2013 and you could resolve it by assembly binding. Otherwise, it is like the msb3277 in VS2013 and there are two situations/solutions.

Comments