NAnt sucks and Rake rocks

1 Feb

In these days I’m moving my build scripts from NAnt to Rake. The main reason for doing this is that I’m moving from external dsl to an internal dsl. Internal DSLs are often the most approachable form of DSLs to write. Unlike external DSLs you don’t need to learn about grammars and language parsing, unlike language workbenches you don’t need any special tools. With internal DSLs you work in your regular language environment.

This means that now I build my build scritps just with ruby. I believe this is a good way to learn this nice language. Rake in fact is nothing more that a Ruby library.

Getting started with Rake and .NET is very easy:

  • Download the Ruby for windows one click installer.
  • Install it
  • Create a file Rakefile.rb (type is text file)
  • Type:
    task :default => :build
    task :build => [:compile, :test, :deploy] 
    task :compile do
      params = '/t:Rebuild /nologo /v:m /p:Configuration=Release src\demo.sln'
      msbuid = 'C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\MSBuild.exe'
      sh "#{msbuid} #{params}" 
    task :test do
     runner = 'tools\\Gallio\\Gallio.Echo.exe'
     assemblies = FileList["src/**/bin/Release/*.Fixture.exe"]
     extension = '' #'/e:TeamCityExtension,Gallio.TeamCityIntegration'
     sh "#{runner} #{assemblies} #{extension}"
    task :deploy do
        sh "echo Task not yet implemented!"
  • Open a command prompt (Start->Run->Cmd)

  • Type: cd c:\[my RakeFile.rb folder] (obviously put your own path in)

  • Type: rake
  • Done!

As you can see here above with rake there is no need to learn some crazy xml syntax. Whit this little script I compile my solution and run all unit tests. No need to write xml, only some ruby code.

Nothing more nothing less.

Technorati Tag: ,,,

8 Risposte to “NAnt sucks and Rake rocks”

  1. Ryan Montgomery febbraio 16, 2009 a 2:52 pm #

    This is truly awesome. Thanks for posting such helpful information. I use Gallio and TeamCity, so this was spot on!

  2. Anonymous marzo 10, 2009 a 5:26 pm #

    Erm… With ant I just “cd …” and “ant” and I’m done… Other than replacing XML with Ruby, why would you recommend Rake over Ant?

    Obviously if you don’t like XML it’s a better choice, but we already have a good Ant setup, might it be worth it to learn Rake or would it just take us two weeks to migrate with nothing gained in the end?

  3. makka marzo 10, 2009 a 7:30 pm #

    Sorry but I never use Ant. I used only NAnt (the .net version)
    Honestly I migrate only some simple NAnt scripts. I left the most complex, but working, in xml.
    One thing is clear: I’ll make the new build scripts only using rake cause ruby is more simple & powerfull that xml

  4. Anonymous marzo 11, 2009 a 2:56 pm #

    Ant and NAnt are pretty much the same… So it sounds like Rake is nice to use, but doesn’t really provide anything Ant or NAnt don’t. Not that user-friendliness isn’t important…

  5. makka marzo 11, 2009 a 7:43 pm #

    Speaking about user-friendliness….
    Just try to do to compare a foreach loop made in xml+nant with a loop done using ruby.

  6. Peter Mounce maggio 18, 2009 a 4:35 pm #

    You might be interested in a project I’m working on; rake-dotnet? and

    • makka maggio 18, 2009 a 8:37 pm #

      It looks very interesting! Nice idea

  7. Rob luglio 22, 2009 a 9:15 pm #

    Nice, I’ve been looking into this more and more. It looks good.

    Still not sure if it’s worth it for me (or my place of work). Our build scripts do a fair amount, but nothing hugely complex. No for loops etc… Typical config file setup, compilation, unit tests, robocopy deploy etc…

    Don’t think we’ll switch just yet. I know people don’t like xml, but at the moment the NAnt documentation is very clear and easy to follow (more so than learning ruby). But eventually we may swap as our build evolves.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: