-
Notifications
You must be signed in to change notification settings - Fork 64
Home
Albacore is a professional quality suite of Rake tasks for building .NET or Mono based systems. You can use our specialized tasks to create the build of your choice. You can jump right into the list of tasks by following the links on the right or follow this quickstart for a guided tour.
Rake is a Ruby DSL that provides a task infrastructure including dependency resolution and chaining, file and path manipulation, parallel task execution, and more. By convention, your build tasks will reside in a rakefile
at your repository root. A rakefile contains executable Ruby code.
The default rake task is used to start the process. Here you can see the default
task depends on the build
and test
tasks.
task :default => [ :build, :test ]
A typical task is a "block" of code that is only executed when you ask rake or when rake is required, by dependencies, to execute it. Tasks can be described (desc
) so that they can be summarized with rake --tasks
or rake -T
.
desc 'Build the release configuration with MSBuild'
task :build do
`msbuild MySolution.sln /target:Build /property:Configuration=Release
end
You may run the default task in the default rakefile by simply executing the rake task on your command line
$ rake
Or you can specify one or more tasks explicitly
$ rake build test
If you're used tinkering with CC.NET, NAnt, or MSBuild "scripts", you probably know to put aside several hours -- if not a day -- to work on your build tasks. The good news is that, with Albacore, you can have a working build in a few minutes. And, it will be maintainable and readable!
First, make sure that you're running on a supported version of Ruby and that you have properly installed Albacore. Create a rakefile
at the root of your repository and include the Albacore gem.
require 'albacore'
Let's look at the common tasks for a .NET solution: version the assemblies, compile the solution in a Release
configuration, and run all of the tests.
task :default => [ :version, :build, :test ]
Most .NET projects have a shared AssemblyInfo.cs
project where all of the static/common assembly attributes are encoded, then that file is linked in each project. Here we use the assemblyinfo
task to overwrite that file with the custom version number for this build.
desc 'Increment the file and assembly version'
assemblyinfo :version do |asm|
asm.version = '1.0.0'
asm.file_version = '1.0.0'
asm.input_file = 'AssemblyInfo.cs'
asm.output_file = 'AssemblyInfo.cs'
end
Obviously, we don't want the version number to be static. You may use one of the Ruby gems that provide version management in a VERSION
file. You would assign the version to the gem's method.
asm.version = bump_version.to_s
Or, maybe your build server manages your build number and you incorporate that into an overall version number. You can pass that to your rake command as an environment variable, right on the command line.
rake version=%your.build.systems.variable.notation.here%
And read it off in your task
asm.version = ENV['version'] || 'some.default.version.number'
We'll do a basic Release configuration build using the msbuild
task, which shells to msbuild.exe
. If you're familiar with the msbuild.exe
command line usage, some of these properties will look familiar to you.
desc 'Build the solution in the Release configuration'
msbuild :build do |msb|
msb.solution = 'MySolution.sln'
msb.targets = [ :Clean, :Build ]
msb.properties = { :Configuration => 'Release' }
end