How A .NET Developer Learned Ruby And Rake, To Build .NET Apps In Windows

I recently decided it was time for me to learn Ruby and Rake – with the specific goal of replacing my NAnt scripts in some projects, due to the high level of complexity and logic that I need in the build process. After asking around the LosTechies crew for advice, and receiving more advice than I had ever hoped for, here’s the basics of what I did to learn Ruby and Rake…

First and foremost – don’t use any kind of IDE. At most, use the “SciTE” text editor that comes with the One-Click installer. It provides simple highlighting, but doesn’t give you any crutches like Intellisense, debugging, etc. Learn the actual language, not an IDE.

  1. Install the Ruby language and runtime via One-Click Installer for Windows. Be sure to enable Ruby Gems.
  2. Read the Wikibooks information on Ruby Programming. The information provided is very easy to read and understand, even for an old VB / C# guy like me. Be sure to read up on the conventions and other basics like objects, methods, and logic constructs.  
  3. Run the “irb – Interactive Ruby Console” from your programs list
    image
    and start hacking away at the basic ruby concepts from the Wikibooks information. You can type in class and method definitions right there in the console and start executing code!
    image
  4. Run a Ruby file: After you’re comfortable with the basics of Ruby, you can start using a text editor to save some code in .rb files, and run them via the ruby command line.
    image
    image
  5. Get Rake by running “gem install rake” from a command prompt. No really. It’s that simple. Isn’t the Gem system great?!
    image
  6. Read about how Rake turned Gregg into an alcoholic (it’s a great Rake tutorial! I promise!) and go through the tutorial.
  7. Then build your own Rake file! Call it “rakefile.rb” so the “rake” command will find it easily.
    image
    image
  8. Read @laribee’s post on using Rake to build .NET apps and learn how to shell out to an MSBuild call, and build your .NET app!
    image

From there, the world is yours! Rake is so stinking simple, and so powerful. You have complete access to all of the Ruby code you could ever want – logic, conditional statements, loops and collections! You can code your entire build process in Ruby, and then script it together with rake tasks! I’m so much happier with Rake than I was with nant. All the angle-bracket XML tax that nant makes you pay was really getting on my nerves, with the complex build systems that I need.

All together, it took me less than 4 hours to create my first usable Rake builds for a sample .NET application. I still have to refer to the language syntax of Ruby, via the Wikibooks entry – I am still learning, after all. But I know the process and how it works well enough, to start using Rake for my project build needs, now!


Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Derick Bailey

Derick Bailey is an entrepreneur, problem solver (and creator? :P ), software developer, screecaster, writer, blogger, speaker and technology leader in central Texas (north of Austin). He runs SignalLeaf.com - the amazingly awesome podcast audio hosting service that everyone should be using, and WatchMeCode.net where he throws down the JavaScript gauntlets to get you up to speed. He has been a professional software developer since the late 90's, and has been writing code since the late 80's. Find me on twitter: @derickbailey, @mutedsolutions, @backbonejsclass Find me on the web: SignalLeaf, WatchMeCode, Kendo UI blog, MarionetteJS, My Github profile, On Google+.
This entry was posted in .NET, Continuous Integration, Education, Rake, Ruby. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://fernandozamorajimenez.blogspot.com Fernando Zamora

    Awesome..I am saving this link for future references..

    Thank you

  • http://www.tobinharris.com Tobin Harris

    Nice post, agree that rake rocks! I’ve posted a few examples of how I’m using with .net too: http://www.tobinharris.com/past/2008/11/4/build-test-refactor-a-simple-net-rake-script/ (hope you don’t mind the link!)

  • http://www.lostechies.com/members/derick.bailey/default.aspx derick.bailey

    great post, Tobin! I’ll be borrowing that rakefile. :)

  • http://sinesignal.com Dale Ragan

    Good post, your’s too Tobin, I am glad that I am not the only person trying to figure out a way to use Ruby to automate my build process and get away from NAnt and all of it’s XML glory. I started using NAnt in hopes that some day it would get away from the XML. I doubt that will happen now, since the project isn’t very active.

    I’ve also been looking at ways to use PowerShell to automate the build process. I am still doing research, but both RAKE and Powershell scripts look promising.

    The next step in my opinion is to come up with a way to either use Capistrano by extending it or find something similar. What ever I find will probably determine which way I go. Capistrano is very powerful and a great way to deploy websites for instance. http://www.capify.org/

  • http://www.tobinharris.com Tobin Harris

    Thanks Derick/Dale! Maybe we should start a .NET rake helper project on GitHub?

  • http://neverrunwithscissors.com Peter Mounce
  • http://therightstuff.de Alexander Groß

    I found JetBrain’s RubyMine helpful for the development of Rake scripts. It also includes a debugger and will hopefully get more developers on Rake and Ruby. From my experience with presenting the Git command line tools recently, the lack of an IDE seems to be a reason *not* to try a new technology or language for some developers.

  • http://dorianward.webs.com/ AlfonsoRush

    which .net framework and version support Ruby And Rake ?

  • http://dawnrocha.wordpress.com/ Frances Johns

    i have read your post.i think your idea is very nice.all .net developer read this magazine and get more knowledge about .net.

  • http://beckfrancer.blogspot.com/2013/07/net-development-allows-current-and-new.html Keaton Hoffman

    Rake is important as well as useful tool used by different people in the community, actually it used by rails but still it doesn’t give me feel that it is used by rails.