Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Fixing Msbuild Error msb3247 - Found conflicts between different versions of the same dependent assembly.

Set MsBuild Verbosity to find out which assemblies conflict:

http://msdn.microsoft.com/en-us/library/ms164311.aspx

msbuild.exe .\Compile.msbuild /verbosity:detailed
...
  There was a conflict between "xxx, Version=1.0.0.0, Culture=neutral, 
  PublicKeyToken=xxx" and "xxx, Version=1.0.12152.1, Culture=neutral, 
  PublicKeyToken=xxx".
      "xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx" was 
	  chosen because it was primary and "xxx, Version=1.0.12152.1, 
	  Culture=neutral, PublicKeyToken=0313e76cb5077f22" was not.
      References which depend on "xxx, Version=1.0.0.0, Culture=neutral, 
	  PublicKeyToken=xxx" [D:\Projects\abc\bin\xxx.dll].
          D:\Projects\abc\bin\xxx.dll
            Project file item includes which caused reference 
			"D:\Projects\abc\src\Web.BuildServer\bin\xxx.dll".
              xxx
      References which depend on "xxx, Version=1.0.12152.1, Culture=neutral, 
	  PublicKeyToken=xxx" [].
          D:\Projects\abc\src\packages\yyy\lib\Net40\yyy.dll
            Project file item includes which caused reference 
			"D:\Projects\abc\src\packages\yyy\lib\Net40\yyy.dll".
              yyy
...

What means yyy references a version of yyy other than the one references by the project or another assembly.

Check the Config files

For Web-Applications the Web.config for all other project types the App.config file (even for class libraries). Make sure you don’t have a <runtime> section pointing to the wrong assembly version.

Fix the error by binding the correct version.

<configuration>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity 
				  name="System.Web.WebPages" 
				  publicKeyToken="31BF3856AD364E35" 
				  culture="neutral"/>
				<bindingRedirect 
				  oldVersion="0.0.0.0-2.0.0.0" 
				  newVersion="1.0.0.0"/>
			</dependentAssembly>
		</assemblyBinding>
	</runtime>
</configuration>

Helpful utilities

https://github.com/mikehadlow/AsmSpy

Comments

Write a comment