I was born in Bulgaria. My immediate family and I relocated to Syracuse, NY in 1995. I completed high school in Syracuse, and then continued my education at Alfred University. My major at Alfred University was Computer Science. I also obtained a minor in Management Information Systems (MIS) to bridge the gap between technology and the business world. One of my future goals is to extend that bridge by obtaining a Master's degree in Business Administration. Boyan is a DZone MVB and is not an employee of DZone and has posted 27 posts at DZone. You can read more from them at their website. View Full User Profile

Tools for Authoring NAnt Build Files

02.21.2008
| 6408 views |
  • submit to reddit

NAnt is a great tool for automating many computer tasks. For a quick introduction, check my previous articles Automating Your Computer Tasks with NAnt and Use NAnt and WinRar to Create a Self Extracting Archive. Authoring NAnt build files can be difficult without a good editor and editing XML is not my favorite thing to do anyway. Having to know all the tags and parameters for each NAnt task, makes it even less desirable. Looking at the current options, you can find several tools for authoring NAnt build files:

While the tools above will do the job, it would be nice if you could edit your build files in Visual Studio and have at least the basic intellisense that the IDE provides. It turns out that editing NAnt build files with VS and having code insight is a pretty easy thing to setup. Here is how it is done:

  1. Install the NAnt schema by copying the file "nant.xsd" form the NAnt distribution to "C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas"
  2. Associate NAnt build files (.build) with the Visual Studio XML editor. This can be done in one of two ways:
    • Create a registry merge file with the following contents and merge it in your registry:
      Windows Registry Editor Version 5.00
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Editors\{412B8852-4F21-413B-9B47-0C9751D3EBFB}\Extensions]
      "build"=dword:00000029
      
    • Make the association through Visual Studio:
      • Open any Visual Studio solution
      • Add a NAnt build file to it
      • Right click on the .build file and choose "Open With"
      • Select "XML Editor" and click on "Set as Default"
  3. Almost there. The last thing is to add the "xmlns" (namespace) attribute to the "project" tag of your build file. If you have copied the NAnt schema file (nant.xsd) to the right place, adding the "xmlns" attribute should list the NAnt schema as one of the available choices. The end result should look like:
    <project
    	name="testProject"
    	default="buildSetup"
    	basedir="."
    	xmlns="http://nant.sf.net/release/0.85/nant.xsd"
    >
    
  4. And Voila! Start typing some XML and you should see a list of NAnt tasks and attributes.
0
Your rating: None
Published at DZone with permission of Boyan Kostadinov, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Sebastian Jancke replied on Fri, 2008/02/22 - 1:03pm

Sounds like the need for a real NAnt Installer wich does this task right out of the box.

Your tutorial work, but I wouldn't want to do it on more than 2-3 dev machines ;-)

Boyan Kostadinov replied on Fri, 2008/02/22 - 1:23pm in response to: Sebastian Jancke

I agree. An installer would be nice and I have thought about creating one on more than one occasion. I will put it on my list of stuff to do :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.