World's Smallest Build Script!

2009-12-29 00:00:00 -0800

Remember how I was all excited about cutting the number of lines out of my assembly info generator by switching from nant to albacore? Well, thanks to a nudge from DaveTheNinja , I’ve realized that I can cut it even further.

Here is an example of a functioning build script for a simple project, using Albacore v0.0.8:

require 'albacore'
assemblyinfotask :buildversioninfo
msbuildtask :default => :buildversioninfo

That’s it! Call rake and it will generate our assembly info and build the project!

YAML Auto-Config To The Rescue!

Ok, so that is technically all you need in the rakefile. However, you will need two more files in the same folder as the rakefile:

  1. assemblyinfo.yml
  2. msbuild.yml

The trick here is that I’m using Albacore’s YAML Auto-Configuration functionality to store all of my configuration information in external files. In each of these two files, you would find the settings that you normally put in the do ... end blocks of the tasks. For example, our simple project may have the following yaml files:

assemblyinfo.yml

company_name: "My Company, Inc."
version: 0.0.1
copyright: "Copyright (C)2009, My Company, Inc."
output_file: "./src/MySolution/assemblyinfo.cs"

msbuild.yml

targets: :rebuild
solution: "src/MySolution.sln"

Even with these external files, though, you have to admit that the amount of work it takes to get a build going with Albacore is on the low end. :)

blog comments powered by Disqus