This project is read-only.

How do I measure task duration?

Jun 5, 2009 at 7:18 PM

I plan on using something like that (from documentation):

<MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Total">

But I don't know how to set $(Start) to current date time in the begining of the task execution.


Jun 5, 2009 at 7:39 PM

You can get out the box task info by running with the additional command line parameter /clp:PerformanceSummary

If you want to time a section, use this:

    <Target Name="Default">
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="MyStartTime"/>
        <Message Text="I'm sleeping..."/>
        <MSBuild.ExtensionPack.Framework.Thread TaskAction="Sleep" Timeout="2000"/>
        <Message Text="Sleep Over!"/>
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(MyStartTime)" Format="Seconds">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        <Message Text="Slept For: $(DTResult)"/>


Jun 5, 2009 at 8:04 PM


That's exactly what I need.

I think it is a common scenario, so documention could benefit from this example.

Jun 5, 2009 at 8:27 PM

No problem. I've updated the sample. Will ship with on Sunday / Monday.