Ramping up with NAnt for automated builds – level 300

At first glance, the NAnt .build files may seem daunting, especially the really long ones, but the documentation for NAnt is superb!


I wanted to start with a real VS solution instead of the trivial HelloWorld .cs file, so I used my Model-View-Presenter demo solution.  Since this was a Visual Studio solution, all I had to do was add a Solution task in the build file.


Here is my build file.  Now if that doesn’t convince you that automated builds aren’t that hard, I don’t know what will!


<project name=”Model View Presenter with Repository” default=”rebuild”>
    <property name=”configuration” value=”release”/>
   
    <target name=”clean” description=”Delete all previously compiled binaries.”>
        <delete>
            <fileset>
                <include name=”**/bin/**” />
                <include name=”**/obj/**” />
                <include name=”**/*.suo” />
                <include name=”**/*.user” />
            </fileset>
        </delete>
    </target>
   
    <target name=”build” description=”Build all targets.”>
        <call target=”build.solution”/>
    </target>
   
    <target name=”rebuild” depends=”clean, build” />


    <target name=”build.solution”>
        <solution configuration=”${configuration}” solutionfile=”MVPWithRepository.sln” />
        <property name=”expected.output” value=”View/bin/${configuration}/View.exe”/>
        <fail unless=”${file::exists(expected.output)}”>Output file doesn’t exist in ${expected.output}</fail>
    </target>
   
</project>