2
votes

I updated the assembly reference in my build tool to use the latest versions(v12) of microsoft.build,microsoft.build.engine and microsoft.build.framework. But while compiling a project using the BuildManager(I use the Rebuild option for compilation) it fails at the Target : CleanWebsitesPackageCore with the error MSB4127: " The "CheckPathAttributes" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Web.Publishing.Tasks.CheckPathAttributes' to type 'Microsoft.Build.Framework.ITask'".

The interested point to be noted is that if i try to compile the project directly by calling MSBuild.exe from the command prompt it compiles fine. While looking at the logs I could see that the target "CleanWebsitesPackageCore" was never getting called during the "clean" part. Wonder why the target gets called when using buildmanager and not while calling msbuild.exe directly on command prompt ?

Anybody has any idea why this is happening like this. Thanks in advance.

1
Too many versions of MSBuild around. The cast error says that you are referencing the wrong version of Microsoft.Build.Framework. On my machine it is version 14 and stored in the GAC.Hans Passant
I have referenced the microsoft.build,microsoft.build.engine and microsoft.build.framework from c:\Program Files (x86)\MSBuild\12.0\bin. So in this should it not get compiled with the MSBuild under 12.0 ?Deepu
That's version 12, not version 14 so would not work on my machine. Presumably not on yours either, given the outcome. Look at the MSBuild.exe.config file you are using, it has a lot of bindingRedirect elements to paper over these version number problems. Your app.config file doesn't have them, it needs them too.Hans Passant
But like i stated in the question the compilation goes fine when i try compiling the project directly by calling msbuild.exe from C:\Program Files (×86)\MSBuild\12.0\Bin. So like i said it doesnt go to the "CleanWebsitesPackageCore" target during the clean part whereas it goes there when i try it through buildManager and fails at that target.Deepu
Whether you are using the correct version of the .targets files is not obvious either. Too many versions of those as well.Hans Passant

1 Answers

4
votes

Reference solution : http://blogs.microsoft.co.il/idof/2008/11/24/what-does-entity-framework-has-to-do-with-msbuild/

App.config add this dependentAssembly

  <runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <dependentAssembly>
       <assemblyIdentity name="Microsoft.Build.Framework"          publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
       <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="12.0.0.0"/>
    </dependentAssembly>
    </assemblyBinding>
  </runtime>