4
votes

I'm getting the MS Build warning "MSB3247: Found conflicts between different versions of the same dependent assembly." when building the a web project (ASP.NET MVC4) under TFS Build 2012.

Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "2.0.0.0" [] to Version "4.0.0.0" [XXXX\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning.

Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.3.0.0" [] to Version "1.5.2.14234" [XXXX\packages\WebGrease.1.5.2\lib\WebGrease.dll] to solve conflict and get rid of warning.

Consider app.config remapping of assembly "Antlr3.Runtime, Culture=neutral, PublicKeyToken=eb42632606e9261f" from Version "3.4.1.9004" [] to Version "3.5.0.2" [XXXX\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll] to solve conflict and get rid of warning.

I know which references are causing these and that's not the problem. I have the relevant binding redirects in place in the web.config file, most of which are set by NuGet when referencing the relevant package(s).

Problem is this is a web project, and it is as if MSBuild is ignoring the binding redirects in the web.config file:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

This warning does occur in the local developer build, but not consistently every time.

The interesting thing is that if I add an app.config file to the web project and place the assembly redirects in there (still keeping the original redirects in the web.config file) the warning goes away, both locally and with TFS Build (where it happens consistently.).

WTF? Any ideas?

2
Do you use different version of nu-get package in your projects? If you update all your projects to the latest version or same version, then you don't need those entries in config files.suresh2
@suresh2 Yes thanks, I know. I do have the latest versions of the NuGet packages. The issue is not that there are different assembly reference versions, the issue is that the bindingRedirects are not honoured. Frequently bindingRedirects are used to address different assembly reference versions for assemblies that are still compatible. E.g. ASP.MVC Optimisation package for references an older version of WebGrease than what is currently the latest for it. That is not a problem - and backwards compatible. NuGet package for WebGrease includes creating an assembly redirection as it should.Jaans

2 Answers

3
votes

I have finally managed to isolate the root cause of this error and identify a few red-herrings.

First, it is a red herring that the issue does not occur where Visual Studio 2012 installed or does not happen on the developer workstations. While the issue occurs consistently on the build servers (TFS Build), it happens on the workstations too, provided the steps "Batch Clean All", followed "Build" are followed.

Second, I can now confirm that the culprit for the MSB 3247 warning is the Microsoft BCL Build Nuget Package:

  • Microsoft.Bcl.Build.1.0.10

It modifies the web application project file, adding the following Import:

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />

<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
  <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
  <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>

If I comment it out of the project file, the issue on the local workstations and the TFS Build Servers goes away.

Unfortunately I do not know what the impact of commenting out the above really means. Can I leave it commented out - what will happen?

The reason this Microsoft.Bcl.Build NuGet package is part of the project is because it's marked as a dependency to the Microsoft.Net.Http NuGet package which we do use. Earlier versions of the Microsoft.Net.Http NuGet package did not have this dependency on Microsoft.Bcl and Microsoft.Bcl.Build packages.

Hope this helps someone.

PS: This has a corresponding, but so far unhelpful forum post here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/faa1b607-50bb-48e3-bd5d-76f4fc02ad4c/ms-build-gives-warning-msb3247-found-conflicts-between-different-versions-of-same-dependent?forum=msbuild

1
votes

I don't have the Bcl.Build stuff anywhere that I can see, and this is the exact error I'm getting on my 2013 TFS build server.

My warnings look like this:

C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1635): Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file:

Which, I already had in my web.config, minus the culture= param, in both my web and api projects.

I'm sorry I don't have any answer for you, I've just gotten my first build to complete, and these are the last two warnings I'm getting.