7

How to run NAnt scripts in command line and get the timings of each task on the log file?

using nant <record> task or 
NAnt -buildfile:testscript.build testnanttarget

This produces console output but I can't see any timing information.

All I want each log message prefixed with datatime.

4

2 回答 2

9

You can use the tstamp task to display the current date/time. Just include it everywhere where you want timing information. It will not prefix each line with a timestamp, but at least you can time some strategic points.

<tstamp />
于 2008-11-30T18:29:55.773 回答
5

Here is a sample of tstamp

    <echo>
    -----------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------
    TASK : INITIALIZE
    -----------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------
    </echo>

    <loadtasks assembly="nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />     
    <!-- http://www.basilv.com/psd/blog/2007/how-to-add-logging-to-ant-builds -->
    <tstamp>            
        <formatter property="timestamp" pattern="yyMMdd_HHmm"/>
    </tstamp>   

    <property name="build.log.filename" value="build_${timestamp}.log"/>

    <echo message="build.log.filename: ${build.log.filename}" />

    <record name="${build.log.dir}/${build.log.filename}"   action="Start" level="Verbose"/>        

    <echo message="Build logged to ${build.log.filename}"/>

    <echo message="Build Start at: ${datetime::now()}" />

</target>
于 2012-07-06T15:56:12.870 回答