Mandy's Tech Blog

Sitting in relative obscurity since 2007…

View My GitHub Profile

Follow me on Twitter

Come work with me!

Site feed

Developing for .NET on the Mac, Part 3: Continuous Integration

If you're not already into automated testing and continuous integration, I highly recommend taking a serious look at it, although making a comprehensive argument for the practice is rather beyond the scope of this article. In any case, if you are into continuous integration, you'll definitely want to set up an instance of CruiseControl.NET (or whatever continuous integration server you use) on a Macintosh--the behavior of Mono varies slightly from platform to platform, so you can't really be sure that your code works properly on the Mac unless you test on a Mac.

Let's get down to business, then, shall we?

Prerequisite:

  1. Grab CruiseControl.NET from their SourceForge page. Get the file named CruiseControl.NET-[Version].zip where [Version] is the latest version number.
  2. Unzip the file and copy the contents of webdashboard into a directory that Apache can access. For the purpose of these instructions, I'll be calling it /web/ccnet.
  3. Open /etc/http/httpd.conf in your favorite editor, and add this to the end:
Alias /ccnet "/web/ccnet"
AddMonoApplications default "/ccnet:/web/ccnet"
<Location /ccnet>
	SetHandler mono
</Location>

If you have your permissions set up correctly, you should now be able to see your CruiseControl.NET dashboard by going to http://your-server/ccnet/. But wait: we don't have the actual CruiseControl.NET service running! To get this set up, we need a few more steps:

  1. Copy the contents of CruiseControl.NET's server directory into some convenient location, such as /usr/local/ccnet.
  2. Edit ccservice.exe.config to your heart's content; make sure that you also create a valid ccnet.config. Neither of these tasks varies from the standard CruiseControl.NET installation procedures, so refer to the CruiseControl.NET site for details on this part.
  3. To get the service running when you first boot your Mac, create a new directory in /Library/StartupItems called ccnet.
  4. In this directory, create two files. One should be called StartupParameters.plist, and the other should be called ccnet. Here's what needs to be in StartupParameters.plist:
{
	Description = "CruiseControl.NET Server";
	Provides = ("ccnet")
	OrderPreference = "Late";
	Messages =
	{
		start = "Starting CruiseControl.NET";
		top = "Stopping CruiseControl.NET";
		restart = "Restarting CruiseControl.NET"
	};
}

And here's what you put in the file called ccnet:

#!/bin/sh
# startup script for service CruiseControl.NET

. /etc/rc.common

case "$1" in
	start)
		ConsoleMessage "Starting CruiseControl.NET"d
		if [ -x /usr/local/ccnet/ccservice.exe ]; then
			/Library/Frameworks/Mono.framework/Versions/Current/bin/mono-service2 -d:/src/ccnet /usr/local/ccnet/ccservice.exe
		fi
		;;
esac
exit 0

Now, if you restart your Mac and navigate to your CruiseControl.NET page, you should have a running instance of ccnet running whatever tests you have set it up to perform.

A couple of notes about the StartupItem I've provided:

Well, that's it for this post. Next time, I'll probably talk about installing Subversion on a Mac. It's not strictly a .NET topic, but it is a quite handy thing to have around, and there are a couple of gotchas to installing it in OS X.

comments powered by Disqus