*UPDATE* If you are confused about the options you have read this first: How to leverage Surface investments for Windows 7

I like Surface and I like MsBuild – so i got motivated in making a build script where we could automatically port our Surface applications for Windows 7 Touchpack.

Of course there is trade offs as conventional multitouch screens are not working with tags – nevertheless it gives us and our customers a value add.

In order for this to make sense, the Surface applications have to be built in a resolution “neutral” way.

On your buildserver or development machine you need to install the MsBuild Community tasks.


Inside the project directory I generate a “libs” directory where I gather all of the assemblies for surface and touchpack.
After this I change the “References” in the surface project to go to the surface version of the assemblies in my libs directory.
Those two steps are mandatory to be able to build on a build server, to build on local development machines they are not required.

The first part of the Script collects all files that need to be changed:

<ProjectFiles Include=”$(SolutionDir)**\*.csproj” />
<CSharpFiles Include=”$(SolutionDir)**\*.cs” />
<XamlFiles Include=”$(SolutionDir)**\*.xaml” />
<AppXamlFiles Include=”$(SolutionDir)**\App.xaml” />

After this I define a Target that modifies the content of these files:

<Target Name=”TouchPack” >

This target consists of lines like:

<FileUpdate Files=”@(CSharpFiles)” Regex=”using Microsoft.Surface” ReplacementText=”using Microsoft.Surface.TouchPack” />

When ever I want to build for Windows 7 Touchpack I call the Touchpack target before my Build target.

You can download a sample build.xml from here.