<nant>

Runs NAnt on a supplied build file, or a set of build files.

By default, all the properties of the current project will be available in the new project. Alternatively, you can set NAnt.Core.Tasks.NAntTask.InheritAll to false to not copy any properties to the new project.

You can also set properties in the new project from the old project by using nested property tags. These properties are always passed to the new project regardless of the setting of NAnt.Core.Tasks.NAntTask.InheritAll. This allows you to parameterize your subprojects.

References to data types can also be passed to the new project, but by default they are not. If you set the NAnt.Core.Tasks.NAntTask.InheritRefs to true, all references will be copied.

Parameters

Attribute Type Description Required
buildfile file
The build file to build.
False
target string
The target to execute. To specify more than one target separate targets with a space. Targets are executed in order if possible. The default is to use target specified in the project's default attribute.
False
inheritall bool
Specifies whether current property values should be inherited by the executed project. The default is true.
False
inheritrefs bool
Specifies whether all references will be copied to the new project. The default is false.
False
failonerror bool
Determines if task failure stops the build, or is just reported. The default is true.
False
if bool
If true then the task will be executed; otherwise, skipped. The default is true.
False
unless bool
Opposite of NAnt.Core.Task.IfDefined. If false then the task will be executed; otherwise, skipped. The default is false.
False
verbose bool
Determines whether the task should report detailed build log messages. The default is false.
False

Nested elements

<buildfiles>

Used to specify a set of build files to process.

</buildfiles>

<properties>

Specifies a collection of properties that should be created in the executed project. Note, existing properties with identical names that are not read-only will be overwritten.

No child element found

<properties>

Examples

Build a project located in a different directory if the debug property is not true.

<nant buildfile="${src.dir}/Extras/BuildServer/BuildServer.build" unless="${debug}" />

Build a project while adding a set of properties to that project.

    <nant buildfile="${src.dir}/Extras/BuildServer/BuildServer.build">
    <properties>
        <property name="build.dir" value="c:/buildserver" />
        <property name="build.debug" value="false" />
        <property name="lib.dir" value="c:/shared/lib" readonly="true" />
    </properties>
</nant>

Build all projects named default.build located anywhere under the project base directory.

    <nant>
    <buildfiles>
        <include name="**/default.build" />
        <!-- avoid recursive execution of current build file -->
        <exclude name="${project::get-buildfile-path()}" />
    </buildfiles>
</nant>

Requirements

Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Tasks