Putting Rake & Albacore in your git repo for instant build awesomeness

Whilst checking out the latest and greatest from the machine.specifications repo, I noticed that their build setup uses Rake.. nothing really all that special there, I thought, lots of projects use Rake.  But taking a closer look, I discovered that the guys got smart and added a small version of Ruby 1.8.6 to their Tools folder, and wrote their build batches in such a way that the repo version of Ruby is used for their build instead of the local version of Ruby (even if Ruby is not installed at all).  This is actually quite brilliant.  The brilliance lies in not requiring Ruby to be directly installed on the build server, or any developer’s machine.


Everything that is not needed in Ruby has been stripped out (like webrick) to make the size of the Rake folder as small as possible. Let’s take a look at how Rake is invoked through the build.cmd


Simple and elegant. Since Ruby isn’t something native to the Windows world, it’s just a folder structure that you can move around, so putting a copy in the repo makes a lot of sense.  There are no strange things to worry about, such as having PowerShell installed if your build scripts using psake.  This is perfect for projects running Mono and developers running Linux or Mac.

So rather than pulling the mspec source and duplicating their setup, I created a skeleton project called BuildWithRuby and pushed it out to github with this exact setup.  Instead of using Ruby 1.8.6 like mspec, I’ve carved out a small copy of Ruby 1.8.7 with Albacore in the Tools folder. You can run either build.cmd from the Windows command prompt (or PowerShell), or run build.sh from your bash prompt. This example has a small Console application with a specifications project (using mspec no less).  The rake script looks like so:


This script will clean, compile assembly info, build, and run specifications for you. Nothing complicated, and very clean.  Hopefully this will help some poor soul who’s stuck without the ability to install Ruby on their build server. 🙂

  1. #1 by Adron on January 18, 2011 - 4:14 pm

    Funny thing, I noticed those rakes bit too. Awesome that you wrote em’ up.

    Now if I can just unwire the #fail around my TD.NET machine specifications I’ll get a blog entry posted in regards to getting those wired up without the #fail. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: