Wat zeggen we over ‘64 bit’

How to install Surface SDK 1.0 SP1 on Windows 7 64 bit and Visual Studio 2010

Suppose a customer asks you to update that wonderful Surface v1 application you wrote ages ago, but you don’t have the SDK installed on your new development machine running Windows 7 64 bit and Visual Studio 2010, you might have a problem, since the SDK cannot be installed. Bummer. But the change has to be deployed tomorrow! Don’t panic, read on. Let me guide you through 15 steps. Let me remind you that this procedure is not at all supported by Microsoft, but it works. And that’s the most important part.

UPDATE: 15/12/2011: Thanks to Florian Haag for the corrections and suggestions. However he’s still struggling with a very annoying bug. Perhaps you can help him out.

1. Relax

The steps are not at all difficult, but you have to remain focussed. Have a coffee, a tea, a fresh pint of beer.

2. Prerequisites

Make sure these are installed:

and you have the Surface SDK 1.0 SP1 file (SurfaceSDKWE.msi) somewhere on your computer.

Create a temporary directory where you will put all the edited files, let’s say c:\Surface.

3. Extract Surface SDK Files

Start the Visual Studio Command prompt with admin privileges and go to the directory where SurfaceSDKWE.msi file is located.

Execute following command in the command window:

msiexec /a SurfaceSDKWE.msi /qb TARGETDIR=c:\surface

Make sure you replace c:\surface with the directory name you created in the previous step. This directory will now contain all installation files.

4. Download Windows 7.0 SDK

Download the Windows 7.0 SDK Web installer. We need to use orca (to patch the surface installer) and corflags (to patch the surface executables).

Important: You need to download Windows 7.0 SDK since this one is working with .Net 3.5. Do not use Windows 7.1 SDK since that one is using .Net 4.0.

04_01 - download Orca

Make sure you check the option .Net development tools.

5. Install Orca

Install Orca. The installer file is located in C:\Program Files\Microsoft SDKs\Windows\V7.0\bin

05_01 - Install Orca

6. Patch msi file

Start Orca and open the SurfaceSDKWE.msi file from the c:\surface directory.

Go to Launch conditions in the left navigation.

06_01 - Remove settings

Make sure you select all highlighted entries, then choose Tables->Drop Row(s) from the menu.

06_02 - Remove settings

Close Orca and save the changes.

7. Patch setupcustomaction.exe

Open the Windows 7 x64 DEBUG Build Environment command prompt (with admin privileges) that has been installed as part of the Windows 7 SDK. It is labeld CMD Shell in the SDK’s start menu folder.

Change the current directory to c:\surface\Microsoft Surface\v1.0 and execute the corflags command:

corflags setupcustomaction.exe /32bit+ /force /nologo

07_01 - corflags

You will receive a warning that you can ignore.

07_02 - corflags

8. Install the Surface SDK

Now, it is time to install the SDK like you would on the original machine configuration.

08_01 - install surface sdk 1.0

9. Patch the executables

In order to run the Surface executables on your 64bit system, you need to patch them with corflags. Execute these commands in the Windows 7 x64 DEBUG Build Environment command prompt with admin privileges (CMD Shell in the SDK’s start menu folder):

cd “C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\GenTag”

for %i in (*.exe) do CorFlags %i /32BIT+ /Force /nologo /UpgradeCLRHeader

cd “C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\Simulator”

for %i in (*.exe) do CorFlags %i /32BIT+ /Force /nologo /UpgradeCLRHeader

cd “C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\SurfaceStress”

for %i in (*.exe) do CorFlags %i /32BIT+ /Force /nologo

cd “C:\Program Files (x86)\Microsoft Surface\v1.0”

for %i in (*.exe) do CorFlags %i /32BIT+ /Force /nologo

10. Verify: Surface Simulator

If all went well, you will now be able to start the Surface Simulator.

10_01 - test simulator

11. Copy the VS 2010 templates

The Surface project and item templates are only installed for Visual Studio 2008, so you have to copy them to the appropriate directory.

You will find the original templates in the directory c:\Program Files (x86)\Microsoft SDKs\Surface\v1.0

11-01 - kopieer templates

Copy the contents of the Item Templates directory to c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Surface\1033

Copy the contents of the Project Templates directory to c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Surface\1033

12. Register the templates

Execute the following command in the command prompt (with admin privileges):

“c:\program files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe” /setup

13. Create a new Surface project in VS 2010

Open Visual Studio 2010, create a new project, but make sure you select “Surface” from the left navigation panel (and not the subdirectory v2.0) and .Net Framework 3.5

13_01 - visual studio

14. Alter the platform target

Make sure you alter the platform target of the project to x86. Believe me, you will forget!

14_01 - output x86

As Florian Haag mentioned in his comment, you could alter this in the project template. This way, you only have to change this once.

15. Build and enjoy the work

That’s it. You have performed all necessary steps. Step 13 & 14 must be repeated for every project.