Apache Ant - .NET Ant Library

| the Apache Ant site |

| Home |

| Projects |

# .NET Ant Library

### .NET Ant Library 1.0

### November 6, 2006 - Apache .NET Ant Library 1.0 Available

Apache .NET Ant Library 1.0 is now available for download as binary or source release.

### Idea

This library doesn't strive to replace NAnt or MSBuild, its main purpose is to help those of us who work on projects crossing platform boundaries. With this library you can use Ant to build and test the Java as well as the .NET parts of your project.

This library provides a special version of the `<exec>` task tailored to run .NET executables. On Windows it will assume the Microsoft framework is around and run the executable directly, while it will invoke Mono on any other platform. Of course you can override these assumptions.

Based on this a few tasks to run well known .NET utilities from within Ant are provided, namely tasks to run NUnit, NAnt, MSBuild and the Wix toolkit.

The initial .NET tasks of Ant (compiler tasks for C#, J# and VB.NET for example) have also been moved to this Antlib and will see further development here.

### Tasks

#### dotnetexec

Runs a .NET executable.

#### nunit

Runs NUnit tests.

#### nant

Invokes NAnt, either on an external file or a build file snippet contained inside your Ant build file.

#### msbuild

Invokes MSBuild, either on an external file or a build file snippet contained inside your Ant build file.

#### wix

Invokes the candle and light executables of the WiX toolkit in order to create MSI installers from within Ant.

### Examples

#### nant

    <project xmlns:dn="antlib:org.apache.ant.dotnet">
      <dn:nant>
        <build>
          <echo message="Hello world"/>
        </build>
      </dn:nant>
    </project>

runs NAnt on the embedded `<echo>` task, output looks like

    Buildfile: test.xml
    [dn:nant] NAnt 0.85 (Build 0.85.1932.0; rc3; 16.04.2005)
    [dn:nant] Copyright (C) 2001-2005 Gerry Shaw
    [dn:nant] http://nant.sourceforge.net
    [dn:nant]
    [dn:nant] Buildfile: file:///c:/DOKUME~1/STEFAN~1.BOD/LOKALE~1/Temp/build1058451555.xml
    [dn:nant] Target framework: Microsoft .NET Framework 1.1
    [dn:nant]
    [dn:nant]      [echo] Hello world
    [dn:nant]
    [dn:nant] BUILD SUCCEEDED
    [dn:nant]
    [dn:nant] Total time: 0.2 seconds.

    BUILD SUCCESSFUL
    Total time: 2 seconds

#### msbuild

    <project xmlns:dn="antlib:org.apache.ant.dotnet">
      <dn:msbuild>
        <build>
          <Message Text="Hello world"
            xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
        </build>
      </dn:msbuild>
    </project>

runs MSBuild on the embedded `<Message>` task, output looks like

    Buildfile: test.xml
    [dn:msbuild] Microsoft (R) Build Engine Version 2.0.50727.42
    [dn:msbuild] [Microsoft .NET Framework, Version 2.0.50727.42]
    [dn:msbuild] Copyright (C) Microsoft Corporation 2005. All rights reserved.

    [dn:msbuild] Build started 15.12.2005 20:21:56.
    [dn:msbuild] __________________________________________________
    [dn:msbuild] Project "c:\Dokumente und Einstellungen\stefan.bodewig\Lokale Einstellungen\Temp\build1543310185.xml" (default targets):

    [dn:msbuild] Target generated-by-ant:
    [dn:msbuild]     Hello world

    [dn:msbuild] Build succeeded.
    [dn:msbuild]     0 Warning(s)
    [dn:msbuild]     0 Error(s)

    [dn:msbuild] Time Elapsed 00:00:00.10

    BUILD SUCCESSFUL
    Total time: 0 seconds