|
CruiseControl.NET : NAnt Task
This page last changed on Mar 14, 2009 by dcameron.
ExamplesMinimalist Example: <nant />
Full example: <nant> <executable>c:\fromcvs\myrepo\myproject\tools\nant\nant.exe</executable> <baseDirectory>c:\fromcvs\myrepo\myproject</baseDirectory> <buildArgs>-D:cvs.executable=c:\putty\cvswithplinkrsh.bat</buildArgs> <nologo>false</nologo> <buildFile>cruise.build</buildFile> <logger>My.Other.XmlLogger</logger> <targetList> <target>run</target> </targetList> <buildTimeoutSeconds>1200</buildTimeoutSeconds> </nant> Configuration Elements:
NAnt output in XmlCruiseControl.NET expects NAnt to generate its output as Xml so that the build results can be parsed and rendered appropriately. To accomplish this, CruiseControl.NET will, by default, launch NAnt using the "-logger:NAnt.Core.XmlLogger" argument. If you want to override this behaviour, specify the logger property in the NAntBuilder configuration in the ccnet.config file. If this element is specified but is empty then NAnt will be started with the default logger (though this may cause some problems for CCNet). It is also possible to instruct NAnt to log its output to an Xml file and then merge the file into the build using the File Merge Task.
NUnit and NAntCruiseControl.NET uses xsl to process the build log and produce html for display on the web page. Since xml is so easy to parse the nunit2 task in NAnt can produce xml output. The tasks must be configured to do that in order for test results to show up on the web page. Typically this is done by adding a formatter element to the nunit2 task and setting the type to be "Xml". Additionally the usefile flag of the formatter element must be set to "false". If it isn't the nunit2 task will try and save the output to a file and not write it out to the build log. <target name="test.unit" depends="compile" description="runs unit tests"> <nunit2> <formatter type="Xml" usefile="false"/> <test assemblyname="${build.dir}\${core.dll}" fork="true"/> <test assemblyname="${build.dir}\${console.exe}" fork="true"/> </nunit2> </target> It would be pretty tedious for developers to read the xml output when they run the build locally. Define a property for the build output type and set it to "Plain" and use the property in the formatter element.. <property name="outputType" value="Plain"/> ... <formatter type="${outputType}" usefile="false"/> ... Then in the ccnet.config file pass in a different value for outputType. <nant> ... <buildArgs>"-DoutputType=Xml"</buildArgs> ... </nant> Accessing CruiseControl.NET build labels in NAntCCNet will pass the current build label to NAnt via the NAnt property CCNetLabel. This means that you can access use this property to, for example, archive the newly built assemblies in a folder with the same name as the build label (this is what we do on CCNetLive . Here's some example NAnt script demonstrating how to do this: <target name="dist.publish" depends="dist"> <ifnot propertyexists="CCNetLabel"> <fail message="CCNetLabel property not set, so can't create labelled distribution files" /> </ifnot> <property name="publish.dir" value="D:\download-area\CCNet-Builds\${CCNetLabel}" /> <mkdir dir="${publish.dir}" /> <copy todir="${publish.dir}"> <fileset basedir="dist"> <includes name="*"/> </fileset> </copy> </target> Integration PropertiesThe following parameters are passed to NAnt as command-line arguments:
Additional informationSee Using CruiseControl.NET with NAnt for more information on working with NAnt and CruiseControl.Net. |
| Document generated by Confluence on Mar 14, 2009 02:55 |