This article will show you the steps neccessary to create a lightweight XNA Build Machine for a continuous integration server. I'm going to assume that you do this on a virtual machine running in Microsoft Virtual Server or VMware Server, which are both available free of cost. Using an isolated environment such as a virtual machine has the advantage of guaranteeing a clean build environment, so you won't run into any nasty surprises when your distribute your games to other people.
Set Up Build Environment
It might come as a surprise that any PC with the .NET Framework 2.0 on it already has the C# compiler, MSBuild and basically just about anything required to compile.NET applications installed.
This is ideal if you want to set up small and self-contained build agents for a continuous integration environment, because you can create extremely lightweight virtual machines to do the compilation work. You don't have to buy another Visual Studio license or even install any clunky IDE on the build machine.
So all we need to do in this first step is to download the .NET Framework 2.0 Redistributable and install it on our virtual machine.
Set Up XNA
XNA Game Studio Express does not come in a stand-alone package and would force you to install Visual C# Express, the SP1 update, possibly the Vista update and XNA GSE on your virtual machine. You can just do so and skip this step, but if you want a slim, optimized build server and don't mind getting your hands dirty, read on!
-
Install the XNA Framework Redistributable and the DirectX Redistributable on the virtual machine. You can find both in your C:\Program files\Microsoft XNA\XNA Game Studio Express\v1.0\Redist directory.
-
Copy the XNA assemblies from the GAC of the XNA GSE 1.0 machine to the GAC of the virtual machine. Doing this is a bit awkward:
My method was to type dir C:\Windows\Assembly\*xna*.dll /s/b in a DOS Prompt to get the files I needed to copy, then copying one assembly after another into an empty folder. I then moved this folder to my virtual machine and drag-dropped the assemblies into C:\Windows\Assembly.
-
On your virtual machine, create the folders all the way down to C:\Program files\MSBuild\Microsoft\XNA\Game Studio Express\v1.0.
Then copy the MSBuild scripts of another machine with XNA GSE 1.0 installed from the same path into the folder you just created.
-
In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework, create a new string value named sdkInstallRootv2.0 and set it to C:\Program files\Microsoft Visual Studio 8\SDK\v2.0\ (even if that path does not exist).
In HKEY_LOCAL_MACHINE\Software\Microsoft\XNA\Game Studio Express\v1.0 (create the folders as needed), set up a new string value named InstallPath and set it to C:\Program files\Microsoft XNA\XNA Game Studio Express\v1.0\, which we'll create in the next step.
-
Create the folder C:\Program files\Microsoft XNA\XNA Game Studio Express\v1.0 and copy the References folder from your XNA machine there.
If you did everything right, your virtual machine should now be able to compile XNA projects on the command line using MSBuild -- all without installing Visual C# or XNA Game Studio Express. Amount of files copied to the virtual machine: Less than 25 MB.
Installing a TeamCity Build Agent
This section is specific to the JetBrains TeamCity continuous integration server. TeamCity uses a network of Build Agents, each of which can run on a different machine and/or OS to perform its builds. Other continuous integration servers, such as CruiseControl.NET, might require that the server runs on the same machine the builds are performed on.
Download the MS Windows Agent installer from the TeamCity front-end. The download links can be found on the Agents tab by clicking on Install Build Agents to the right. Run this installer on your virtual machine. Installing the Agent as a system service is a good idea since the virtual machine is going to run unattended.
When the configuration page pops up, give your agent a good name (I used Windows XP (.NET/XNA)) and enter the url under which your server can be reached. If you installed the TeamCity windows setup and didn't have a web server running before, it will probably be http://myserver:80/. If your TeamCity server is running on a linux machine, try http://myserver:8111/ instead.
Next, we need to manually tell our new build agent that our virtual machine indeed has the Microsoft .NET 2.0 Framework installed and is able to run TeamCity's MSBuild projects (this is normally detected automatically when Visual Studio is installed on the machine running the agent.)
Open your C:\buildagent\conf\buildAgent.properties file
and add this line to the end of the file:
system.DotNetFramework2.0
Now we somehow need to know whether an agent is capable of building XNA projects, otherwise . Of course, we can't just build XNA projects on any .NET 2.0-capable agent, so we also need to distinguish between normal .NET 2.0 agents and agents with the XNA build system installed. Otherwise, TeamCity could try to build XNA projects on a normal .NET 2.0 build agent, causing random build failures.
Let's use the tags XNA1.0 and XNA1.1 to mark
XNA-capable agents. XNA 1.1 stands for XNA 1.0 Refresh, which is
internally labelled XNA 1.1, so the tag isn't too far off :). Add these
lines to the end of aforementioned file as well:
system.XNA1.0
system.XNA1.1
We can now configure our projects to only build on agents with the XNA1.0 or XNA1.1 tag set on the Agent Requirements page.
That's it. Fire up your agent, wait a minute and it should be ready to compile your XNA projects without requiring you to ever touch the virtual machine hosting your build agent.
Post new comment