<nant> Task

# <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 `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 `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 `inheritrefs` to true, all references will be copied.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
buildfile | file | The build file to build. | 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
target | string | The target to execute. To specify more than one target seperate 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
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 `if`. 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.

##### <property>

Sets a property in the current project.

Note: NAnt uses a number of predefined properties.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
name | string | The name of the NAnt property to set. | True
value | string | The value to assign to the NAnt property. This attribute's properties will not be automatically expanded! | True
dynamic | bool | Specifies whether references to other properties should not be expanded when the value of the property is set, but expanded when the property is actually used. By default, properties will be expanded when set. | False
overwrite | bool | Specifies whether the value of a property should be overwritten if the property already exists (unless the property is read-only). The default is true. | False
readonly | bool | Specifies whether the property is read-only or not. 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 `if`. 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

### Examples

- Define a `debug` property with value true.

      <property name="debug" value="true" />

- Use the user-defined `debug` property.

      <property name="trace" value="${debug}" />

- Define a read-only property. This is just like passing in the param on the command line.

      <property name="do_not_touch_ME" value="hammer" readonly="true" />

- Define a property, but do not overwrite the value if the property already exists (eg. it was specified on the command line).

      <project name="property-example">
        <property name="debug" value="true" overwrite="false" />
        <echo message="debug: ${debug}" />
      </project>

  Executing this build file with the command line option `-D:debug=false`, would cause the value specified on the command line to remain unaltered.

      [echo] debug: false

##### </property>

#### </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 (0.92.4543.0)