# NAnt Task

## NAnt

### Description

Runs the NAnt build tool.

You can either use an existing build file or nest a build file (snippet) as a child into the task. If you don't specify either, NAnt's default build file search algorithm will apply.

### Parameters

Attribute | Description | Required
buildfile | External build file to invoke NAnt on. | No.
vm | Same as dotnetexec's vm attribute. Specify the framework to use. | No.

### Parameters specified as nested elements

#### target

`target` has a single required attribute name - specifies a target to be run.

#### property

`property` has two required attributes. name and value that specify name and value of a property that is to be defined in the NAnt invocation.

#### build

This element allows no attributes. You can nest a NAnt build file into it and NAnt will be executed on that. You can also nest a build file snippet instead and Ant will wrap the necessary NAnt `<project> around it.`

### Examples

Let NAnt search for a *.build file in the (Ant) project's base directory and execute the default target in it:

    <nant/>

Let NAnt execute the targets named foo and bar in the build file nant.build in Ant's basedir and pass the property `-D:test=testvalue` to it:

          <nant buildfile="nant.build">
            <target name="foo"/>
            <target name="bar"/>
            <property name="test" value="testvalue"/>
          </nant>

Define a build file embeded into the task, let NAnt execute the echo target of that build file.

          <nant>
            <target name="echo">
            <build>
              <project basedir="." default="empty">
                <target name="empty"/>
                <target name="echo">
                  <echo message="this is NAnt"/>
                </target>
              </project>
            </build>
          </nant>

Run NAnt's echo task:

          <nant>
            <build>
              <echo message="this is NAnt"/>
            </build>
          </nant>

Copyright © 2003-2004 The Apache Software Foundation. All rights Reserved.