Skip to content

Commandline Task Options

derickbailey edited this page Aug 12, 2010 · 4 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.

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

Of course, this example won’t actually execute since these are not valid options… the point is that you can now specify any command line parameters you want on any commandline task.

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|
  #you can set the working directory using nunit.command_directory
  #this is a poorly named option... should be .working_directory
  #will fix the option name in the next release.
  nunit.command_directory = "src/tests/bin/release/"

  #note: the path_to_command is relative to the working directory
  nunit.path_to_command = "../../../../nunit/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 .path_to_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.

Clone this wiki locally