NAnt SDK Documentation - v0.92

NAntTask Class

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

For a list of all members of this type, see NAntTask Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Task
         NAnt.Core.Tasks.NAntTask

[Visual Basic]
<TaskName(Name:="nant")>
Public Class NAntTask
    Inherits Task
[C#]
[TaskName(Name="nant")]
public class NAntTask : Task

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

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.

Example

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

Namespace: NAnt.Core.Tasks

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

NAntTask Members | NAnt.Core.Tasks Namespace