CaubleStone Ink

.Net development and other geeky stuff

nAnt: Getting your machine ready

Posted on January 27th, 2009

In this post we will get your pc ready to use nant.  The examples and links will be geared towards VS2008 however they will also work for VS2005.  VS2003 requires a bit more but can be done in very similar ways.

  1. If you have not already done so go get nAnt.  This example and all future ones will use version 0.85
  2. Extract the file to a location on your c: drive like c:\tools\nant
  3. Add the location of the bin folder to your path.  So in this example it would be: c:\tools\nant\bin or c:\tools\nant\0.85\bin depending on how you extracted your files.
  4. Copy the file nant.xsd from the c:\tools\nant\schemas folder to the following location(s):
    • C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas — for visual studio 2005
    • C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas — for visual studio 2008

Now that you have done all that we are going to open visual studio. This next bit will work in either 2005 or 2008 so the instructions will be the same. Once you have opened visual studio.

  1. Go to the Menu:  Tools -> Options
  2. Navigate in the left hand tree to the Text Editor section
  3. Select the File Extentions item.  Your options dialog should look like this:
    options_dialogIn the Extension box I want you to enter the word: build

    • Note: I use build as the extension for my build files for nant vs xml so I know what they are out of the box.
    • For this option dialog you do not put any periods in the extension box.
  4. Next select XML Editor from the list and then hit the Add button.  Your options dialog should then look like this:
    options_dialog_with_buildNow select OK and off we go.

That’s it for the setup.  If you want to test this add a new XML File to a project in Visual Studio and call it something like  You should then get intellisense for your build files.  The root level object will be project.  As you will notice because we added the file extension you also get the auto-complete benefits of the xml editor.  Things like adding the closing tag, quotes, etc.

That takes care of the first part of our nAnt setup.  In the next article I’ll walk you through adding Item and Project templates that you can use and customize for easily adding build files and projects that already have build files to your project.  After which we will get into the usage of nAnt and setting up a common build file that you can reuse from project to project.