Mark Needham

Thoughts on Software Development

Nant include task – namespace matters

with 4 comments

We’ve been trying to include some properties into our build file from a properties file today but no matter what we tried the properties were not being set.

We eventually realised that the build file has an XML Namespace set on the project element.

<project name="..." xmlns="">

It turns out that if you want to include a properties file in your build file, like so:

<include buildfile="properties.xml" />

…you need to put the namespace on the project attribute of that file as well, otherwise its properties don’t get picked up.

Our properties file therefore needs to look like this, assuming that we have a namespace set on the build file.

<project name="properties" xmlns="">
	<property name="foo" value="bar" />

What’s a bit confusing is that on the NAnt documentation page for the include task it says that project element attributes are ignored! That’s not what we found!

Be Sociable, Share!

Written by Mark Needham

February 3rd, 2009 at 10:43 am

Posted in Build

Tagged with ,

  • User

    wow you just saved me. i was pulling out my hair

  • Tom

    I’m coming from an Ant background where I made heavy use of the immutability of properties and the ability to load property files, e.g. have a file called ‘’ that contained values like,


    My takeaway from this article is that I need get into my mental Tardis and travel back in time to the early days of Ant when I didn’t have quite such strong property support.

    Nice article, shame about the message.

  • Tom

    I’m afraid that moving from a JVM based environment to a dot net environment is very much like travelling back in time when it comes to tools support.

  • VC

    Thanks much for publishing this info; I stuggled for 2
    weeks before locating this. Now it’s fine after I made the changes
    in view of the NS issue above. Still unclarified issue: How did
    Nant pick up the include file before 2 weeks in my env when I did
    not put any NS to it and why it started not considering the
    including files all of a sudden until i put the NS in it. Thanks