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