May 2005 Entries

Adding Visual Studio .NET 2003 Support for NAnt

 

Ok, I spent a little time yesterday working on this so I thought I'd post it for future reference and to share. You can add support for NAnt build scripts within Visual Studio .NET 2003 with 4 steps. First, you need to create a template file that will be loaded every time you add an item through Visual Studio .NET. Something like the following will work well, remember to reference the schema.

<project 
xmlns="http://nant.sf.net/schemas/nant.xsd" 
default="build"></project> 

Save this file to the following directory:

C:\Program Files\Microsoft Visual Studio .NET 2003
\VC#\CSharpProjectItems

Now we need to create a .vsdir file so Visual Studio .NET knows about our new template. I've added a new vsdir file in the following directory:

C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\LocalProjectItems\Utility

Add the following content to your vsdir file, I called mine nant.vsdir.

..\..\default.build|0|NAnt Build File|10|A blank NAnt build file|0|0|0|default.build

Copy over the the nant.xsd schema file from the NAnt\schema directory to the following directory for Visual Studio:

C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml

Now we just need to tell Visual Studio to use the HTML Editor when editing our .build files. We can do this by make a quick addition to the registry. Run regedit and navigate to the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio
\7.1\Editors\{C76D83F8-A489-11D0-8195-00A0C91BBEE3}\Extensions


and add a DWORD entry with a key of “build” and the value of 28. Close Visual Studio .NET 2003 if you have it open, reopen it, right-click on a project to add a new item and you should see something like this:

Automated Build

 

Do you have an automated build system in place for your development? This morning I came in, ran my NAnt script which cleaned my Build directory out, built every project within my solution, copied over the .exe's, .dll's, .config's, .xml's and .manifest files, then it subsequently invoked my WiX script that built a complete MSI installer package, including the web service deployment. Wow, all this and I haven't even had my coffee for the day.