# Scripting with rake

DevFeed: [Scripting with rake](<https://devfeed.tech/articles/scripting-with-rake-33367.md>)

Original publisher: [Read original article](<https://timkellogg.me/blog/2011/04/20/scripting-with-rake>)

Published: 2011-04-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Tim Kellogg](<https://devfeed.tech/sources/tim-kellogg.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [make](<https://devfeed.tech/topics/make.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [NUnit](<https://devfeed.tech/topics/nunit.md>), [Visual Studio](<https://devfeed.tech/topics/visual-studio.md>)

Tags: [asp-net](<https://devfeed.tech/tags/asp-net.md>), [cli](<https://devfeed.tech/tags/cli.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [make](<https://devfeed.tech/tags/make.md>), [net](<https://devfeed.tech/tags/net.md>), [nunit](<https://devfeed.tech/tags/nunit.md>), [rake](<https://devfeed.tech/tags/rake.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [visual-studio](<https://devfeed.tech/tags/visual-studio.md>)

## AI overview

This article explains how to use Rake as a Ruby-based build and scripting tool. It compares Rake with make, Ant, and NAnt, discusses dependency and file tasks, and describes using Albacore for .NET builds and related development automation.

## Source excerpt

Rake is a great twist on traditional make (honestly, I never really liked Ant or NAnt). On the surface it looks more like make than Ant or Nant, but you can leverage the full syntax and standard library of Ruby (and there's no weird rules about tabs). As a .NET developer, albacore augments rake nicely with tasks for MSBuild (building Visual Studio projects and solutions), NUnit, ASP.NET precompiler, modifying your AssemblyInfo.cs (like for bumping the version number), and many more.Since rake is just ruby code, you can do just about anything, but most file manipulation routines are even easier to write in rake, because most everything is already imported and ready to use. Unlike make, Ant, and Nant, you don't have to start a separate project just to develop tools to use in a rakefile, just write a ruby function!Building dependencies firstA lot of people who aren't already familiar with build languages make some common mistakes. Among them, not using dependencies correctly. For instance, given a website solution that references frameworkmsbuild :framework do |msb| msb.solution = 'framework/src/framework.sln'endmsbuild :website do |msb| msb.solution = 'src/website.sln'endtask :default => [:framework, :website]The default task is the task that's executed when you just type rake at the CLI. The reason this is terrible is that it's procedural and inflexible. Now, if I do rake website the build fails because framework hasn't been built yet. Instead, each task should specify what other tasks it directly relies on. This script should change to:msbuild :framework do |msb| msb.solution = 'framework/src/framework.sln'endmsbuild :website => :framework do |msb| msb.solution = 'src/website.sln'endtask :default => :websiteThis way both rake and rake website work the same. This leverages rakes dependency framework that is at the core of all build languages.Using file tasksThe other point that people often forget is that build languages are oriented around files. Make tasks were ori