Valid TaskActions are:

AddDays (Required: Format, Value Optional: Start Output: Result)

AddHours (Required: Format, Value Optional: Start Output: Result)

AddMilliseconds (Required: Format, Value Optional: Start Output: Result)

AddMinutes (Required: Format, Value Optional: Start Output: Result)

AddMonths (Required: Format, Value Optional: Start Output: Result)

AddSeconds (Required: Format, Value Optional: Start Output: Result)

AddTicks (Required: Format, Value Optional: Start Output: Result)

AddYears (Required: Format, Value Optional: Start Output: Result)

CheckBetween (Required: Start, End Optional: UseUtc Output: BoolResult)

CheckLater (Required: Start Optional: UseUtc Output: BoolResult)

Get (Required: Format Optional: UseUtc Output: Result)

GetElapsed (Required: Format, Start Optional: End, UseUtc Output: Result)

Remote Execution Support: NA

Namespace: MSBuild.ExtensionPack.Framework
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 3.5.0.0

Examples

Xml Copy imageCopy
<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <PropertyGroup>
        <Start>1 Jan 2009</Start>
    </PropertyGroup>
    <Target Name="Default">
        <!-- Let's Time how long it takes to perform a certain group of tasks -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="MyStartTime"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <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"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Slept For: $(DTResult)"/>
        <!-- Get the elapsed days since the start date -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Days">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Days Since $(Start): $(DTResult)"/>
        <!-- Get the elapsed minutes since the start date -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Minutes">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Minutes Since $(Start): $(DTResult)"/>
        <!-- Get the elapsed hours since the start date -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Hours">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Hours Since $(Start): $(DTResult)"/>
        <!-- Get the total elapsed time since the start date -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Total">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Total Elapsed Time Since $(Start): $(DTResult)"/>
        <!-- Get the time in the specified format -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Date / Time: $(DTResult)"/>
        <!-- Get the UTC time in the specified format -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss" UseUtc="true">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="UTC Date / Time: $(DTResult)"/>
        <!-- Check if its later than a given time -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="CheckLater" Start="14:10">
            <Output TaskParameter="BoolResult" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Later: $(DTResult)"/>
        <!-- Check if the current time is between two times -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="CheckBetween" Start="14:10" End="14:25">
            <Output TaskParameter="BoolResult" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Between: $(DTResult)"/>
        <!-- Test Add time targets based on start time provided in AddTimeStart. -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="AddTimeStart"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Add Time To: $(AddTimeStart)"/>
        <!-- Add days -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddDays" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Add 30 days: $(DTResult)"/>
        <!-- Verify add days -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" End="$(DTResult)" Format="Days">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Days Since $(Start): $(DTResult)"/>
        <!-- Add hours -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddHours" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 hours from time: $(DTResult)"/>
        <!-- Verify add hours -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" End="$(DTResult)" Format="Hours">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Hours Since $(Start): $(DTResult)"/>
        <!-- Add milliseconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMilliseconds" Start="$(Start)" Value="3000" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="3000 Millisecond from time: $(DTResult)"/>
        <!-- Verify add milliseconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" End="$(DTResult)" Format="MilliSeconds">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Milliseconds Since $(Start): $(DTResult)"/>
        <!-- Add minutes -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMinutes" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 minutes from time: $(DTResult)"/>
        <!-- Verify add minutes -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" End="$(DTResult)" Format="Minutes">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Minutes Since $(Start): $(DTResult)"/>
        <!-- Add months -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMonths" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 months from time: $(DTResult)"/>
        <!-- Add seconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddSeconds" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 Seconds from time: $(DTResult)"/>
        <!-- Verify add seconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" End="$(DTResult)" Format="Seconds">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Seconds Since $(Start): $(DTResult)"/>
        <!-- Add ticks -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddTicks" Start="$(Start)" Value="3000" Format="dd MMM yy HH:mm:ss:fff">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="3000 ticks from time: $(DTResult)"/>
        <!-- Add years -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddYears" Start="$(Start)" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 Years from time: $(DTResult)"/>
        <!-- Test Add time targets based current time. -->
        <!-- Add days -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddDays" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 days from time: $(DTResult)"/>
        <!-- Add hours -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddHours" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 hours from time: $(DTResult)"/>
        <!-- Add milliseconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMilliseconds" Value="3000" Format="dd MMM yy HH:mm:ss:fff">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="3000 Millisecond from time: $(DTResult)"/>
        <!-- Add minutes -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMinutes" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 minutes from time: $(DTResult)"/>
        <!-- Add months -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddMonths" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 months from time: $(DTResult)"/>
        <!-- Add seconds -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddSeconds" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 Seconds from time: $(DTResult)"/>
        <!-- Add ticks -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddTicks" Value="3000" Format="dd MMM yy HH:mm:ss:fff">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="3000 ticks from time: $(DTResult)"/>
        <!-- Add years -->
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="AddYears" Value="30" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="30 Years from time: $(DTResult)"/>
    </Target>
</Project>

Inheritance Hierarchy

System..::..Object
  Microsoft.Build.Utilities..::..Task
    MSBuild.ExtensionPack..::..BaseTask
      MSBuild.ExtensionPack.Framework..::..DateAndTime

See Also