Configurations let you modify target behaviors. A configuration is just a target that sets a number of properties associated to a another target.
Classical example of configurations are debug and release. As their names suggest, they are used to configure a debug or a release build, respectively. Let's see a build file fragment that illustrates how to implement configurations:
<?xml version="1.0"?>
<project
name="helloworld"
default="run">
...
<target
name="debug"
description="Configures a debug build">
<property
name="project.config"
value="debug" />
<property
name="build.debug"
value="true" />
<property
name="package.name"
value="${nant.project.name}-${project.config}" />
</target>
<target
name="release"
description="Configures a release build">
<property
name="project.config"
value="release" />
<property
name="build.debug"
value="false" />
<property
name="package.name"
value="${nant.project.name}" />
</target>
<target
name="build"
description="Builds HelloWorld">
<mkdir dir="${build.dir}/${package.name}/bin" />
<csc
target="exe"
debug="${build.debug}"
output="${build.dir}/${package.name}/bin/helloworld.exe">
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
...
</project>
Depending on which configuration is executed, the build target will behave differently. For example, the command
nant debug build
tells NAnt to first execute the debug target, which is actually the configuration, and then to execute the build target. The debug configuration sets the build.debug property to true, causing the build target to generate a debug version of the executable.
Appendix A, Build File Examples provides a complete example of how to implement configurations.