How to Build Compact Framework Projects with TFS 2010

If you have a Visual Studio 2008 solution with one or more Compact Framework (also referred to as “Smart Device”) projects that you’re trying to build with TFS 2010 or MSBuild 4.0, you’ve probably hit one of the following errors:

error MSB4062: The "Microsoft.CompactFramework.Build.Tasks.AddHighDPIResource" task could not be loaded from the assembly Microsoft.CompactFramework.Build.Tasks

Or,

error MSB4062: The "Microsoft.CompactFramework.Build.Tasks.GetDeviceFrameworkPath" task could not be loaded from the assembly Microsoft.CompactFramework.Build.Tasks

The problem is a setting in the application configuration file for MSBuild (MSBuild.exe.config), which you’ll find in your .NET Framework directory (e.g. “C:\Windows\Microsoft.NET\Framework\v4.0.21006” for x86 systems or “C:\Windows\Microsoft.NET\Framework64\v4.0.21006” for x64 systems).

You’ll need to remove this element:

 <dependentAssembly>
  <assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" 
    publicKeyToken="b03f5f7f11d50a3a" 
    culture="neutral"/> 
    <bindingRedirect 
      oldVersion="0.0.0.0-99.9.9.9" 
      newVersion="10.0.0.0"/>
</dependentAssembly>

This will stop MSBuild from trying to load the non-existent 10.0 version of the Microsoft.CompactFramework.Build.Tasks assembly.