Navigation

Search

Categories

On this page

MSBuild fail on specific days

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Wednesday, January 21, 2009
Wednesday, January 21, 2009 11:20:59 AM (Mountain Standard Time, UTC-07:00) ( All things Microsoft )

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>