Sign Silverlight XAP with TFS Build

I have a Silverlight application that is set up for Continuous Integration with Team Foundation Server. As part of the build, I needed to sign the XAP with a certificate. To accomplish this I will be using a command line tool SignTool.exe. The tool is automatically installed with Visual Studio and it has to exist on the TFS Server.

Steps below walk through the setup process.

1) Check-in the certificate into TFS. This must be done so that the build server downloads it into the workspace.

2) Update the Post-build event on the Silverlight project

In Project Properties, select ‘Compile’ option, then select the ‘Build Events…’ button.


We will be modifying Post-build event command line.  Select the ‘Edit Post-build …’ button.


Enter the SignTool command to execute:

"C:\Program Files (x86)\Windows Kits\8.0\bin\x86\SignTool.exe" sign /v /f
$(SolutionDir)\..\MyCert.pfx /p CertPassword $(TargetName).xap

Specify the path to the certificate relative to the solution directory so that it can be found during the Build.

3) Verify that your build definition is set up to download the certificate into its workspace.