views:

252

answers:

2

Continuing the Hidden Features series for Nant.

One of the things I learned recently was

<xmlpoke>

Allows you to replace text in an xml file.

e.g. http://stackoverflow.com/questions/678096/setting-debugfalse-in-web-config-as-part-of-build/678137#678137

Question will be updated to show the top voted answers

+2  A: 

Sometimes you want a particular target to run multiple times - say, if its behavior is configurable by setting properties.

<call>

Allows you to directly invoke a target and it's dependencies.

See Also

Bevan
+2  A: 

You can parameterise your NAnt scripts.

To pass a value on the commandline, use -D:

nant -D:database.server=localhost rebuild.database

Then, in your script, create a subtarget that verifies the configuration and gives help if necessary:

<target name="require.database.server">
    <fail message="Define database server using -D:database=&lt;host&gt;"
          unless="${property::exists('database.server')}"/>
</target>

You can even use a default value:

<property name="database.server"
          value="${environment::get-machine-name()}"
          overwrite="false" 
          unless="${property::exists('database.server')}"/>
Bevan