Continuous Integration Gotcha NAnt empty elements

Written by Brett Veenstra

For those of us using the TeamCity continuous integration tool, I ran across a gotcha this morning that I will forget very soon.

The problem

When running NAnt script on my local machine “in developer mode”, everything runs fine. However, once it goes to TeamCity, it puts up a general error:

> Could not include build file 'X:\teamcity-BuildAgent\work\684ab6ff82f1a29a\build\'. 
> Object reference not set to an instance of an object.

In the end, my offending entry was:

<fileset id="cube.load.files">
  <!-- <include name="${build.mxl.dml.dir}\foo.mxl" asis="true"/> -->

Here’s my NAnt file pattern. I use a set of for a development machine. I also create a for the TeamCity run. Then I create a “wrapper” NAnt file that includes both the CORE build script as well as the *.properties.xml file for the given environment.

This has worked very smoothly in the past so this morning it was rather frustrating to receive the error. The inspiration for this methodology was inspired by Jean-Paul’s excellent NAnt series. I highly encourage you to check it out.

Back to the problem… When running under TeamCity, I get a failure to include a build file, but everything works when running on a development machine.

The Solution

Remove EMPTY elements from the XML-formatted NAnt file (or close them using shorthand). For some reason, it looks as if TeamCity’s NAnt runner is parsing those files before sending them over to NAnt (guessing here).

And once I cleaned up this empty element, it worked! Interesting how this yet another reason why XML is the bane of developers.

<fileset id="cube.load.files" />