Monday, June 28, 2010

Automating your Windows Mobile 6.x builds on TFS 2010

If you have recently attempted to build your Windows Mobile 6.x code using the new TFS 2010 recently you might have received this error:

(81): The imported project "C:\Windows\Microsoft.NET\Framework64\v3.5\Microsoft.CompactFramework.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

It is pretty clear as to what the issue is, so how do you fix this? Well you can install Visual Studio 2008 (Device development is not supported on VS 2010) on your build server - not nice, but then this won't fix my issue here. Notice the path above. The smart device project is looking in the 64-bit location for the Compact Framework build targets files: C:\Windows\Microsoft.NET\Framework64. As my build server is running on Windows Server 2008 R2 - which only comes in 64-bit edition, it makes sense to use 64-bit tools.

The easy fix for this type of configuration is to install the .NET Compact Framework 3.5 Redistributable which can be found here: Install that package on the build server which will allow your code to compile.

Then download the .NET CF 3.5 Power Toys - this will give your the Compact Framework build targets that MSBuild needs. This can be downloaded from here: Again that package needs to be installed on the build server. You may think it is odd that the build targets are included in this package, then so did I. They are also included with VS2008 but installing the Power Toys is a much better solution as it's a lot smaller install.

Now remember with my configuration I mentioned earlier, I am running 64-bit server, as there is no 64-bit edition of .NET CF Power Toys, the build targets get installed to the 32-bit location on the file system: C:\Windows\Microsoft.NET\Framework\v3.5 but by default my build definition is set to "Auto" which will choose the 64-bit edition first, then use the MSBuild path to find the build targets. This will still result in a failed build because the 64-bit edition will be running from: C:\Windows\Microsoft.NET\Framework64\v3.5 and that path doesn't contain the files we need. So a simple change to the build definition to use x86 is needed:

Once you make that change, queue a new build and your build should succeed.
As for getting VS 2008 talking to TFS2010, I'll write a post on getting that to work. There is a lot of content on this in the community but a lot of it didn't work for me.


Anonymous said...

Thanks Simon! That was exactly the problem that I was having and you had me back up and running in minutes.

Paul said...

Oh man! This is great, it's exactly the problem I was having too (except my project is WinCE)! I had changed the property to "x86", but not in conjunction with downloading the power toys. Thanks for the post!

Paul G said...

Where is that dialog box?