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.