Rake in .NET projects – installation and setup

Posted by – November 18, 2009

.NET Logo
Recently I have rewritten all MSBuild scripts which I used in ByteCarrot project to Rake. I made the decision about changing build solution mostly because I required something what works not only under Windows but also on other operating systems. After rewriting turned out that Rake is a great solution for tasks for which it was created and can be used not only with Ruby/RoR projects but also with other technologies like .NET and Mono. It is really awesome multi-purpose tool. Today I would like to show you how to install and configure Rake on Windows operating system in order to start using it in your projects. Ruby installation First of all, because Rake is based on Ruby language, you will need an interpreter. You can download Ruby distribution from its official website but I do not recommend that because there is only installer for version 1.8.6 which is quite old. Other packages for Windows on this website are in a form of compressed archives and do not contain some additional, required libraries. In my opinion the best option is to download one of preview version of installer for Ruby 1.9.1-p129 (rubyinstaller-1.9.1-p129-preview1.exe) available on RubyForge. ByteCarrot project to Rake. I made the decision about changing build solution mostly because I required something what works not only under Windows but also on other operating systems. After rewriting turned out that Rake is a great solution for tasks for which it was created and can be used not only with Ruby/RoR projects but also with other technologies like .NET and Mono. It is really awesome multi-purpose tool. Today I would like to show you how to install and configure Rake on Windows operating system in order to start using it in your projects.

Ruby installation

First of all, because Rake is based on Ruby language, you will need an interpreter. You can download Ruby distribution from its official website but I do not recommend that because there is only installer for version 1.8.6 which is quite old. Other packages for Windows on this website are in a form of compressed archives and do not contain some additional, required libraries. In my opinion the best option is to download one of preview version of installer for Ruby 1.9.1-p129 (rubyinstaller-1.9.1-p129-preview1.exe) available on RubyForge.

Ruby Logo

When the installer is on your hard drive, start installation. There is nothing magic in the installation process but you should remember that Rake does not work properly when Ruby in installed in C:\Program Files directory (probably because of space in the path). Because of that leave the default installation path or change it to something without spaces like for example C:\Ruby.

Last thing you should do to be able to use Ruby is adding the location of its binaries to the %Path% environment variable. In my case this variable was extended with C:\Ruby\bin path.

Now you can check if everything works by executing from command line two following commands:

ruby –v
gem -v

The output from console should be:

C:\>ruby –v
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
C:\>gem –v
1.3.4

Rake installation

Now, when Ruby is installed and you are sure that it works you can take care of Rake. The most popular and safe way to install Ruby extensions and libraries (including Rake) is mechanism called Gems. In order to install Rake using Gems execute following command from command line:

C:\>gem install --remote rake

The output from console should be:

C:\>gem install --remote rake
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Updating class cache with 0 classes...
Installing RDoc documentation for rake-0.8.7...

When the command will finish do not close command line window yet. At the end execute one more command to be sure that Rake is installed properly:

C:\>rake –V

The output from console should be:

C:\>rake –V
rake, version 0.8.3

Congratulations! You have managed to install Rake and you are ready to write your first build script. More about Rake can be found on official site of the project. Example Rake scripts can be found in ByteCarrot source code on CodePlex.

Hey, keep in touch!! Follow me on Twitter, @marcinobel or subscribe to this blog.
1 Comment on Rake in .NET projects – installation and setup

Respond | Trackback

  1. c.barca says:

    thank you, it work fine.

Respond

Comments

Comments