NAnt intellisense in Visual Studio

NAnt is a phenomenally cool tool for automating build scripts. Coding NAnt build files feels natural to me: unix shell script style functions and xml style syntax. However, getting all the parameters just so is a bit intense.

Visual Studio can provide intellisense for NAnt, if it has an xsd file to use for reference. NAnt comes with an nant.xsd, and some pretty good docs for installing it. This is great for NAnt tasks, but doesn't handle NAntContrib's features.

Clint describes a technique here and here for using NAnt to build the nant.xsd file. He was using an older version of NAnt though, so I needed to modify Clint's code slightly. While I was in there, I grabbed other dlls in the nant bin folder too.

Here is a zip file with a .build file, a .reg file, and the resulting nant.xsd it builds. The build file builds the nant.xsd, and copies nant.xsd into the correct spot in Visual Studio. The registry key tells Visual Studio it's there.

The build file assumes you're using NAnt v. 0.85 release. If you're not, grab the xmlns reference from the top of the original nant.xsd provided in the NAnt install, and copy it into the build file.

To get intellisense in Visual Studio, run the build file, and load the registry key. Restart Visual Studio, and you're golden.

Clint and others have discussed creating a Visual Studio template file, so you could add a new file of type "NAnt Build File" from within Visual Studo. Since I'm usually copying a build file from another project as a starting point, I haven't found the need to sit down long enough to figure this out.

Rob

posted @ Wednesday, November 29, 2006 10:05 AM

Print

Comments on this entry:

# re: NAnt intellisense in Visual Studio

Left by Thomas Höhler at 3/2/2007 7:04 AM
Gravatar
Thanks Rob,

this saved my day.

Thomas

# re: NAnt intellisense in Visual Studio

Left by Henrik at 6/2/2007 2:17 PM
Gravatar
Here's what you need, no registry keys here! (man!)

1. Add nant.xsd to visualstudio8/xml/schemas.
2. Restart VS2005.
3. Write this code, and you'll get intellisense for it once you've specified the xmlns:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />
&lt;project name=&quot;NAnt Build Sample&quot; default=&quot;debug&quot;<br />
xmlns=&quot;http://nant.sf.net/release/0.85/nant.xsd&quot;&gt;<br />
<br />
&lt;/project&gt;

Piece of cake.

# re: NAnt intellisense in Visual Studio

Left by Sven Cipido at 7/20/2007 7:41 AM
Gravatar
Hi Rob,

Txs for your answer. Meanwhile I had found a solution. If I open a build script and then through the xml menu take the option "Create Schema" then the intellisense works for that script.

The build script that you provided, should normally work. But I have talked with some collegueas of me and they also said that sometimes it didn't work correctly and we have to create a seperate schema.

txs again.

Sven Cipido

ORDINA Belgium

Your comment:



 (will not be displayed)


 
 
 
Please add 7 and 4 and type the answer here:
 

Live Comment Preview: