title: MSBuild "GenerateFakes" Error MSB4127, MSB4060
body: <p>When building using Visual Studio 2013 the GenerateFakes succeeds, it uses the same path to the same target file.</p>
  
  <p>When building via MSBuild 12.0 (Same version shipped with Visual Studio 2013) I get the following two errors.</p>
  
  <p><strong>Error #1</strong></p>
  
  <pre><code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.targets(128,5): error MSB4127: The "GenerateFakes" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.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.QualityTools.Testing.Fakes.GenerateFakes' to type 'Microsoft.Build.Framework.ITask'. 
  </code></pre>
  
  <p><strong>Error #2</strong> </p>
  
  <pre><code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.targets(128,5): error MSB4060: The "GenerateFakes" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
  </code></pre>
  
  <p>I could successfully build using MSBuild 11.0 on an old machine which was using Visual Studio 2012. </p>
  
  <p><strong>Could the issue be related to some sort of missing binding redirect?</strong></p>
  
  <p>The following link contains a similar error but for another framework: <a href="http://social.msdn.microsoft.com/forums/vstudio/en-US/2772a075-4e2f-42af-9e7a-2228b794368e/msbuild-crashes-with-a-message-task-could-not-be-instantiated-exception" rel="nofollow">http://social.msdn.microsoft.com/forums/vstudio/en-US/2772a075-4e2f-42af-9e7a-2228b794368e/msbuild-crashes-with-a-message-task-could-not-be-instantiated-exception</a></p>
  
  <p><strong>Just noticed that deleting the FakeAssemblies folder in all projects cures the problem, however once I build in Visual Studio again the error comes back.</strong></p>