Geeks With Blogs
David Atkinson

Before we start thinking about database continuous integration, described in an earlier blog post, we need to pick a build tool in which we define the commands for our build process.

NAnt is a .NET version of Ant, a tool to drive build processes. Like MSBuild, Microsoft’s equivalent, NAnt build scripts can be driven by continuous automation tools, such as TeamCity, CruiseControl, Bamboo and many others.

Yes, it would be possible to drive your scripts with DOS batch files or PowerShell, but NAnt specializes in build-related processes, which is why I decided to adopt this as the scripting engine for my SQL Server continuous integration set-up.

Typing NAnt into Google comes up with , its SourceForge page. It’s not immediately obvious, but to download NAnt you need to expand the chosen version and select the download option from the left-hand tree.


After downloading I extracted the contents of to c:\nant-0.91

NAnt.exe can be found in C:\nant-0.91\bin

To test that my set-up was working I simply ran nant.exe from a command prompt only to get:


log4net:ERROR XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.

Googling the error message comes up with the solution. The zip file apparently protecting me from myself and needs to be ‘unblocked’.

In windows explorer, invoke the zip file properties and click Unblock.


Extract the zip contents once more, and try running nant.exe. The error should have gone away.

Another issue I encountered when installing NAnt on a colleague’s machine is that unless the FULL version of the .NET Framework is installed, another error occurs.

Could not load file or assembly 'System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Again, I found the solution via a Google search:

Simply install the Full .Net Framework and try again.

Now let’s test NAnt using a very simple example.

For this I created a text file C:\temp\

<?xml version="1.0"?>
<project name="Hello World" default="hello">
<property name="hello.string" value="Hello World" />
<target name="hello" description="Echoes 'Hello World'">
<echo message="${hello.string}" />

And invoke it from a command prompt as follows:

C:\nant-0.91\bin\nant.exe -buildfile:C:\temp\

This should return:

NAnt 0.91 (Build 0.91.4312.0; release; 22/10/2011)

Copyright (C) 2001-2011 Gerry Shaw

Buildfile: file:///c:/temp/

Target framework: Microsoft .NET Framework 4.0

Target(s) specified: hello


[echo] Hello World


Total time: 0 seconds.

Now we have a way of invoking NAnt manually from a command prompt, which is very useful for testing and troubleshooting build script issues outside of your continuous integration process.

Overall I was disappointed that the experience of installing NAnt wasn’t nearly as smooth as I would have expected given the popularity of the tool. The errors that were returned when the zip file hadn’t been unblocked, and when the Full .NET framework hadn’t been installed, were less than useful, so hopefully this blog post will assist others encountering similar issues.

Now that we’ve got NAnt installed and working, we’re in a position to build a new database directly from source control. This will be the topic of my next post, "How to build a database from source control"



Technorati Tags:
Posted on Monday, April 16, 2012 2:08 PM SQL Server , Continuous integration , NAnt | Back to top

Comments on this post: Installing NAnt to drive database continuous integration

# re: Installing NAnt to drive database continuous integration
Requesting Gravatar...
yes this is very usefull
Left by M.P.SINGH on Feb 21, 2013 7:54 AM

Your comment:
 (will show your gravatar)

Copyright © David Atkinson | Powered by: