Thirteen Days a Week

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 15 Comments | 0 Trackbacks

News

Archives

Post Categories

Monday, January 24, 2011 #

For the past month or so, I’ve been working on a Silverlight project for a client.  I’m not much of a UI developer to begin with, so getting to know Silverlight has been interesting to say that least.  There’s certainly no shortage of things I need to learn about it.  My most recent endeavor has been getting a CI build setup on our TFS server for our Silverlight applications.  I certainly didn’t think this was going to be such a challenge, but there’s doesn’t seem to be a lot of good information about how to accomplish this.  What follows is the result of much time spent searching Google, browsing various blogs and support forums that ultimately led to a successful build on our TFS server.

First, the easy part.  You’ll need to install both the Silverlight SDK as well as the Silverlight Toolkit on your build agent.  The SDK of course is needed to compile Silverlight applications and the Toolkit contains the MSBuild targets.

Next, because the Toolkit’s MSBuild targets are 32 bit, you need to configure your build to run the 32 bit version of MSBuild.  You can accomplish this by editing your build definition in Visual Studio and setting the MSBuild Platform property to X86:

Build

 

Once you’ve done this, you’ll be able to successfully build your Silverlight applications, provided you don’t have any web projects in your solution that reference your Silverlight XAPs.  If you do have a web project that references your XAPs and you run a build now, you’ll end up with an error about MSBuild not being able to copy a XAP to your web project’s ClientBin directory.  To get around this, you’ll need to manually edit the project file for the web project.  Find the line in your project file that references the XAP file.  This will be the line that begins with <Content Include=”ClientBin\….”.  Add a Condition to it, as shown below:

ProjectFile

 

Finally, add another reference to the XAP file, this is the <None /> element shown above.  So the net effect is that the XAP is ignored when the build runs on the server and not ignored when it runs on your dev desktop.