Commandline Task Options

daniellee edited this page May 9, 2011 · 6 revisions

Many of the tasks that Albacore includes are wrappers around command line tools. For example, the MSBuild task, NUnit task, and NCoverConsole tasks are all set up to call out to a command line tool. These commandline tasks have a few common options that allow you to control how the command line is called.

.command Attribute

All command line tasks provide a .command attribute to specify the location of the tool to be executed. The tool can be any arbitrary command line tool, including built-in system commands.

Example:

nunit :test do |nunit|
  nunit.command = "tool/nunit-console.exe"
  #... other options here
end

Arbitrary Parameters

In order to make these tasks more flexible and capable of running with options that are not yet supported by the task configuration, directly, we have added a generic .parameters attribute to all tasks that run a command line tool. This will allows you to use any arbitrary parameters that you want, when calling the task. For example:

msbuild :build do |msb|
  #... other options here
  msb.parameters "i'm a parameter!", "/some:value", "/whatever=idontknow"
end

Working Directory

There are times when the tool that is being called needs to be executed from a specific working directory. For example, NUnit may need to be called from a certain working directory, so that it can correctly find all of the necessary assemblies. In cases like this, you can set the working directory of the commandline task.

nunit :unittests do |nunit|
  nunit.working_directory = "src/tests/bin/release/"

  #note: the .command is relative to the working directory
  nunit.command = "tool/nunit-console.exe"

  #note: for the NUnit task, the path to the assemblies
  #is also relative to the working directory
  nunit.assemblies "tests.dll"
end

Note that the .command setting is relative to the working directory. If you change the working directory, then you must specify the location of the command that is being executed, relative to the working directory.

Only the current task call will be executed in the specified working directory. In the above example, the working directory will be reset after the NUnit command is executed.