Home > Development > NAnt Overriding properties from the console

NAnt Overriding properties from the console


If you have a property in your project which may change depending on a commandline switch you can override it using the -D:name=value commandline switch.

I the sample below I am overriding the property from the commandline.

<?xml version="1.0" encoding="utf-8"?>
<project name="nantexamples" default="cli-property-overrides" xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd">
	<property name="mode" value="default"/>
	<target name="cli-property-overrides">
		<echo message="The value of mode is ${mode}" />
	</target>
</project>

[/Users/blairdavidson/Projects/NantExamples] nant -D:mode=cli-value -buildfile:NantExamples.build
NAnt 0.86 (Build 0.86.2898.0; beta1; 8/12/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///Users/blairdavidson/Projects/NantExamples/NantExamples.build
Target framework: Mono 2.0 Profile
Target(s) specified: cli-property-overrides

[property] Read-only property “mode” cannot be overwritten.

cli-property-overrides:

[echo] The value of mode is cli-value

BUILD SUCCEEDED – 0 non-fatal error(s), 1 warning(s)

Total time: 0 seconds.

[/Users/blairdavidson/Projects/NantExamples]

Advertisements
Categories: Development Tags: , , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: