Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

OMG Rake!

Rake is just… lovely. There’s no other way to describe it. I just moved our XEVA Framework to rake and ended up with this build script weighing in at only 35 lines:

Check out the :harvest task where I’m requiring an external file that’s contains code for bundling up the various build outputs, currently just .dll and .pdb files. The file looks like this:

I’m in love with Rake — and the idea of executable configuration in general — for a few reasons:

1) I can take my scripts down to a reasonable size. The NAnt script for this simple build weighed in at a hefty 162 lines. These two files combined hover around 65. That’s much better signal to noise and it only gets better with the more complex scripts.

2) I can make new tasks lickity split. With ruby you just write some code inside a task. It’s easy to leverage popular libraries like Hpricot for XML poking and peeking and such. No need to compile tasks and manage separate projects just for build code.

3) I can see what’s happening! Ruby is a very flexible language. I can use it’s tricks to pimp out my build scripts and I don’t need to sift through angle bracket madness. Note how I opened up the Dir class to define a new method, exists?. Ah the joys of ruby. We can make things somewhat familiar to our .NET teams while keeping it idiomatic. With tools like IronRuby this prospect get’s even juicier.

Getting Started

If you’re just getting started with rake, you need ruby first. The “one click install” at the official Ruby site is what I’m using and it’s a pain-free setup. There’s plenty on Google, but I recommend giving the Rails Envy boys a click for a super-basic-but-effective primer. Remember the sh method is your friend and, when in doubt, RTFM!

This entry was posted in builds, rake, Ruby, tools. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

10 Responses to OMG Rake!

  1. alberto says:

    Yeah, I know, but makes it harder to sell it to other people. I’m not myself totally sold on that. You could also do that with nant or other commonly used tools, and that eases some pains, but also causes others. It can be a problem with breaking changes (i.e this worked in ruby/rake x.y.z when we built it, but not anymore, or having to tell everyone you have to install foo/upgrade your bar for this to work).

    Maybe silly, maybe not, but it’s a cause of friction you don’t have if it’s included in the project itself.

  2. Dave Laribee says:

    @alberto – you probably *can* but I’d encourage you to think about ruby as a platform similar to a JVM or the .NET framework. Chances are you’ll go deeper with rake and start using various gems and such. Then it really becomes a platform for build automation more than just the rake app itself.

  3. alberto says:

    Can you include ruby & rake in your tools folder? I don’t see it in xeva and I like projects to be self-containing.

  4. This is awesome! Funny, how you sometimes find stuff just at the moment you need it. I am definitely going to use this for a project I am doing. If I never have to use NAnt again…that’s ok by me.

  5. Ray Vega says:

    You expressed the exact same feelings I had when I started using Python in place of NAnt for my build scripts for the exact same reasons. Nice to see as well yet another make the leap away from “XML Hell” (or as Jeremy Miller puts it “XMHell”)

    I, too, blogged about the joys of switching recently:

    http://lexicalclosures.blogspot.com/2008/07/snake-bitten-by-python-rip-nant.html

  6. chris donnan says:

    I moved to rake for a project a few months back. It took thousands of lines of crappy nant, msbuild, ccnet etc and reduced it to a like 80 lines of lovely ruby. :) Homogeneity has huge value, not 9 syntax representations (some custom CC net stuff, some custom msbuild tasks – in C#, some bat files, some random roll your own xml, xml for ccnet, xml for etc etc.)

    Great stuff. I am happy to see more .net folks using rake in a place where it can add value. I blogged about this a while ago..

    http://chrisdonnan.com/blog/2008/05/10/how-i-have-fit-ironpython-ruby-jruby-and-ironruby-into-my-existing-net-projects/

    Hope all is well;

    -Chris

  7. Dave Laribee says:

    @Ayende – You’re like the official ambassador of executable configuraiton to the .NET world! :) I’ve been using capistrano and rake for a while now with some rails side projects, I just finally got off my ass and rake-enabled our .NET stuff.

    @Tom – Easier to read is a big part of it, but the feedback cycle and task testing story for custom tasks is much, much better. It’s just code after all. Is the build talk online somewhere?

  8. This is nice – a lot easier to read than XML, IMHO.

    This is kind of what I was trying to get at at ALT.NET Canada in the build talk – that perhaps XML isn’t the best language to script in.

  9. Welcome to the executable configuration world :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>