Intellisense for NAnt Build Files (VS 2005 and 2008)

2010 January 17
by r.claypool

nant

Step 1. Make VS recognize a .build file as an XML file.

  1. Right-click a .build file in the “Solution Explorer” and select “Open With …”
  2. In the “Open With” dialog, select “XML Editor” and “Set as Default”

vs-2005-2008-open-with-dialog

Step 2: Enable intellisense for .build files.

Get the schema file for NAnt:

Copy it to the “xml\Schemas” subdirectory of your VS installation:

  • Note that you can check this path via Tools > Options > Text Editor > XML > Miscellaneous

schema-location-option

Specify the schema to use within Visual Studio:
  • Open the file so that it appears in a Visual Studio editor window.
  • Click the file’s editor window (to activate it) and specify the schema to use (within the “Properties” window).
    change-schema-properties
  • Note that this dialog has changed from VS 2005 to 2008:

Visual Studio 2005
(VS 2005)

Visual Studio 2008
(VS 2008)

If all of that is not enough,  make sure to enter an xmlns and make sure it is equal to the xmlns specified in the XSD schema

!!!!! Even though the schema is available at http://nant.sf.net/release/0.86-beta1/nant.xsd and http://nant.sourceforge.net/release/0.86-beta1/nant.xsd, you must reference the former url in your build file because it is the one referenced in nant.xsd. !!!!!

Here is an example of what I mean:

<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd" name="MyProject">
  <!-- stuff here -->
</project>

Hope that helps someone.  Happy Programming!


Attribution: The ant photo in this post is used with permission (CC BY-SA 2.0) by Jeff Kubina
2 Responses leave one →
  1. 2010 June 3
    Sebastian permalink

    Yes! Thanks so much – this really helped me out. This is one of the best articles I’ve seen so far explaining how to import XSDs into Visual Studio. : )

  2. 2010 July 26

    Thanks, I just used this today. My NAntBuilder trail expired, and this got me back on track. Very helpful

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS

This work by Robert Claypool is licensed under a Creative Commons Attribution 3.0 United States.