I recently did a MSBuild script for a colleage to zip some files and move them to a file server and email them to two recipients.
The script should only run on a specific day (Sunday), and fail with an error if it is not that day.
Using the MSBuild Community Tasks Project from Tigris makes this a trivial exercise.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="Build">
<Time>
<Output TaskParameter="DayOfWeek" PropertyName="DayOfWeek" />
</Time>
<Message Text="It's Monday!" Condition=" '$(DayOfWeek)'=='Monday' "/>
<Message Text="It's Tuesday!" Condition=" '$(DayOfWeek)'=='Tuesday' "/>
<Error Code="1" ContinueOnError="false" Condition="'$(DayOfWeek)'=='Monday'" Text="Stop everything, it's monday!"/>
<Message Text="Everything is ok"/>
</Target>
</Project>