NAnt Frequently Asked Questions

NAnt logo (link to home page)

Contents

Building NAnt
Mono
How can I avoid getting a NullReferenceException when building NAnt on Mono?
Visual Studio.NET
How can I debug NAnt using Visual Studio.NET?
General
Framework support
What framework does NAnt target by default?
How do I change the target framework?
Third-party tools
Visual Studio.NET
How do I get Visual Studio.NET to recognize a .build file as an XML file?
How do I enable intellisense for .build files?

Building NAnt

Mono

How can I avoid getting a NullReferenceException when building NAnt on Mono?

There are currently some regressions in Mono CVS (bug #55996) with regards to AppDomain unloading which cause a NullReferenceException when building NAnt.

Zoltan Varga implemented a workaround for this issue: set the environment variable MONO_NO_UNLOAD to any value before running NAnt:

$ export MONO_NO_UNLOAD=1
$ make clean
$ make
$ mono bin/NAnt.exe clean build
                    

Visual Studio.NET

How can I debug NAnt using Visual Studio.NET?

NAnt cannot be built using VS.NET, as VS.NET (prior to VS.NET 2005) is unable to handle dependencies between projects very well.

However, you can compile NAnt using the NAnt build scripts, and then debug NAnt using VS.NET. To do this, open the NAnt solution file in VS.NET and change the following debugging properties of the NAnt.Console project (using Project -> Properties -> Configuration Properties -> Debugging):

  • Debug Mode: Program
  • Start Application: <select NAnt.exe that you just compiled>

Finally, just run NAnt in VS.NET (using Debug -> Start or just F5), and when VS.NET informs you that there were build errors, and asks whether you still want to continue : select Yes.

General

Framework support

What framework does NAnt target by default?

As from NAnt 0.85, NAnt by default targets the framework on which its running.

How do I change the target framework?

NAnt supports three ways for changing the target framework:

  1. From the command line, using the -t[argetframework] argument:

    NAnt.exe -t:net-1.0
                                
  2. By changing the default target framework in the NAnt configuration file:

    <frameworks>
        <platform name="win32" default="net-1.0">
            ...
        </platform>
    </frameworks>
                                
  3. By changing the value of the system property nant.settings.currentframework:

    <property name="nant.settings.currentframework" value="net-1.0" />
                                

Third-party tools

Visual Studio.NET

How do I get Visual Studio.NET to recognize a .build file as an XML file?

  1. In "Solution Explorer", right-click a .build file and choose "Open With".
  2. In the "Open With" dialog, select "HTML/XML Editor" and click the "Set as Default" button.

How do I enable intellisense for .build files?

Copy the schema for your version of NAnt from the schema folder in the NAnt distribution to:

Visual Studio .NET 2003

The "Common7\Packages\schemas\xml" subdirectory of your Visual Studio.NET installation.

Visual Studio 2005

The "Xml\Schemas" subdirectory of your Visual Studio 2005 installation.