0
votes

I need to rebuild a set of custom TFS build activities, and am getting the following error. I'm under the impression from googling around that this results from MS pulling the Microsoft.Build.Engine package out of the 4.0 Framework and including it with the VS tooling.

The primary reference "Microsoft.TeamFoundation.Build.Workflow, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build.Engine, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.

Any ideas what I can do about this? I am targeting the 4.5 framework, have VS 2012 and 2013 installed, though using 2012 to build this package.

3

3 Answers

0
votes

I had a similar problem, and, in general, Lee Higgitt's answer is correct. The reason is that Microsoft.TeamFoundation.Build.Workflow v.12 has a dependency on Microsoft.Build.dll v.12, which I've learned somehow requires that the build be done using Microsoft.Build.Tasks.v12.0.dll. If the MSBuild property VisualStudioVersion is set to 12.0 (e.g. when the sln is a VS 2013 sln), then Microsoft.Build.Tasks.v12.0.dll is used. In contrast, if VisualStudioVersion is set to 11.0 (e.g. when it's a VS 2012 sln), then
Microsoft.Build.Tasks.v4.0.dll is used. The v4 Tasks dll produces the error; the v12 Tasks dll doesn't. In general, then, upgrading the sln to VS 2013 will fix it.

However, if one is using a TFS build server, it's a different story. Even if VisualStudioVersion is 12.0, since C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe is used to do the build and only the v4 Tasks dll is present in that directory, the build is forced to use the v4 Tasks dll, causing the error to be produced.

You might think that forcing the build to use the x86 version of MSBuild would do the job, but, C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe still only contains the v4 Tasks dll!

From my command line testing, when the build is done with C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe, the v12 Tasks dll is present in that dir and is used, so the build works!

Also, I've oversimplified the problem above. I tried copying the v12 Tasks dll and Microsoft.Build.Utilities.v12.0.dll into C:\Windows\Microsoft.NET\Framework\v4.0.30319, but that didn't allow the instance of msbuild in that directory to build my sln successfully.

In short, I think this must be a Microsoft bug. I'll create a ticket with them and update this thread as I learn anything.

Update:

Here's the issue on Microsoft Connect.

Update 2:

As one can see from the the issue on Microsoft Connect, for the TF Build case, if one uses the template that comes with TFS 2013, this issue is not repro'ed (though I haven't had a chance to confirm this myself yet). So, to fix this issue...

  • If it's happening locally, upgrade the solution to VS 2013.
  • If it's on a TFS build server, make sure the logic of the latest template from Microsoft is being used.
1
votes

Check the reference to Microsoft.Build.Engine or the reference path. The MsBuild binary and its dependencies has moved from the c:\windows\Microsoft.NET folder to: C:\Program Files (x86)\MSBuild\12.0\Bin

0
votes

I've been having the same issue in Visual Studio 2012.

I've re-created my solution in VS2013 and all of the issues go away! Not really a solution but if you've got access to 2013 then I recommend you try it.