Setup – Jenkins and Silverlight
Introduction
This is a short article on how to setup your Jenkins environment to build your Silverlight applications. In this article I will assume that you’ve already followed the steps I outlined in my previous articles called “Setup – Apache and Jenkins” or my article called “Setup – Jenkins and Windows” and that you already have a working Jenkins build server set up on a windows environment. If you’re still in the process of setting these environments up, then I would suggest that you follow the steps in those articles before you continue with this article.
Table of Contents
- Background
- Installing the Build Components
- Configuring Different MSBuild Paths
- Creating your Jenkins Job
- Conclusion
Background
As I’ve mentioned on a previous blog my team got involved in some Silverlight development. So, I’ve been meaning to write a little article on how to use some of the toolsets that we’ve been using on some of our other projects, like Jenkins. This shouldn’t be a problem to set up, but there are a few lessons that I picked up seeing that you have to build your Silverlight applications using the X86 version of MSBuild. This became quite interesting seeing that most of our services are built for X64 seeing that they’re deployed server side. So, we had to find some way to be able to build both the client and the server components on the same build server/slave. This meant that we couldn’t use the Windows Environment Variables, but had to configure Jenkins to be aware of the different versions for MSBuild. I’ll take you through how this can be done, but be aware that you should have at least version 1.42 of Jenkins installed seeing that there were some issues with the previous builds which didn’t take the MSBuild paths into consideration on the slaves.
Installing the Build Components
So, before we switch to Jenkins you’ll need to install some Silverlight components for your build to work. To do this you should install the following on the server where you want your job to run:
- Silverlight SDK
- Silverlight Toolkit
There might be other custom component that you’ll need based on what you used in your application, but this should be sufficient for you to run MSBuild.
Configuring Different MSBuild Paths
Now that you have your Silverlight components installed you’ll need to run open your Jenkins environment and configure it have the MSBuild paths for your X64 and X86 versions of MSBuild. So, follow the steps below and you should have this done in no time. I assume that you already have the “Jenkins MSBuild plugin” and the “Team Foundation Server Plug-in” installed on your Jenkins environment. If you haven’t yet you can follow the instructions as found in my article called “Jenkins – TFS and MSBuild”.
So, open your Jenkins Dashboard where you’ll see a link called “Manage Jenkins” that looks like:
Once the Manage Jenkins page has loaded you should click on the link for “Configure System” as seen below:
Once the configuration screen has loaded you’ll see there’s a section for MSBuild that looks like this:
At this stage you can click on the “Add MSBuild” button which will open up a section that looks like:
In my case I’ll name this MSBuild Configuration “X86MSBuild” and will enter the path to my MSBuild.exe file which is usually found at: “C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe” into the “Path to MSBuild” textbox. I won’t be selecting to “Install automatically” seeing that I’ve already installed my components for the build. When you’re done you can do the same for your X64 version of MSBuild. If you’re done with that you can save your configuration, which should take you back to your Jenkins Dashboard. And that concludes this section…
Creating your Jenkins Job
Configuring a Jenkins Job for your Silverlight application works more or less the same as creating any other type of Job, except for the fact that you should have now point to your X86 version of MSBuild. So, in this example you can click on the “New job” link on your Dashboard that looks like:
This will open the New Job page which looks like:
In this case I’ll call my Job “MyNewSilverlightJob” and I’ll select the “Build a free-style software project” option and when you click on the “OK” button you’ll have the Configure Job page where we’ll configure our Job to do get the latest version of our source code from Team Foundation Server (TFS). This page should look like the image below when it opens:
So, to configure TFS quickly we’ll scroll down to the section that has to do with the TFS configuration that looks like:
You should configure this with all of your own TFS detail. Once you’ve configure this we’ll configure the “Build Triggers” by going to the section that looks like:
In this case I opted to Build periodically with a 10 minute interval. Now that we’ve done this we’ll configure our Build step by selecting the option “Build a Visual Studio project or solution using MSBuild” option from the drop down button that looks like:
Once you’ve selected this you should see that configuration section that comes up that looks like:
In this section you should see the “X86MSBuild” MSBuild configuration in the MsBuild Version dropdown, which should be the one that you select for your Silverlight project. Once you’ve done this you should be able to configure the path to your build file and your command line arguments and save your new job configuration.
Conclusion
As I said in the beginning, this is a simple and quick article on how to get Jenkins to build you Silverlight applications for you. I hope this helps someone out there to run X64 and X86 builds on their projects. I must say that I haven’t found anything that this simple tool can’t do relatively easily yet. I may have another article coming out soon on how to get my Silverlight Unit Tests to run under Jenkins and how I would go about automating deployments and package builds.
Cheers 🙂