Making NAnt more expressive with Boo
Boo provides the ability to script with a more expressive language in NAnt build files via the boo task. As an example of the possibilities of what you can do with Boo in NAnt, check out the following two tasks, which first runs FxCop and then reads the output of a FxCop task so as to summarize the number of Critical Errors in FxCop’s result file.
<property name="fxcop.xml"
value="${build.dir}bin${build.config}fxcop.xml"/>
<target name="fxcop" depends="build">
<fxcop>
<targets>
<include name="${build.dir}bin${build.config}${library}" />
</targets>
<arg value="/out:${fxcop.xml}" />
</fxcop>
</target>
<target name="fxcop-analysis" depends="fxcop">
<boo>
import System.IO
fpath = Project.Properties['fxcop.xml']
numerror = 0
using input = File.OpenText(fpath):
for line in input:
if line =~ /Level="CriticalError"/:
numerror++
print("There were ${numerror} Critical Errors")
</boo>
</target>
The fxcop-analysis target grabs a reference to the fxcop.xml property and uses Boo’s easy IO processing to read the file’s contents. Boo’s built-in handling of regular expressions makes finding the number of occurrences of critical errors a snap too.
XML by itself is fairly limiting when it comes to expressing behavior; however, with the addition of Boo or even the extensibility provided by creating custom tasks, you can add a higher level of functionality. Plus, with Boo, the level of effort is frighteningly low!

August 18th, 2007 at 11:31 am
[…] Test Early ยป Making NAnt more expressive with Boo (tags: nant boo) […]