MSBuild string formatting

I was in danger of yak shaving today, trying to work out how to put a timestamp in the filename of a zip file created by my MSBuild project. This is the project run on the automated build machine twice a day. I want to zip up all the build assemblies and archive them as one of the last steps. The SDC extensions have a handy zip task, but formatting the time into the filename is tough.

The time task (which, incidentally, had to be added to Microsoft.Sdc.Tasks) returned the time with colons in it, and colons are not valid characters in filenames. There weren't any string formatting tasks, so my best idea so far is to use an Exec task to call
echo %Time:~0,2%-%Time:~3,2%-%Time:~6,2% > currenttime.txt

and then read the file back in. I had toyed with using XPath to read the NUnit run time from the XML results file, but I didn't have a yak-grade razor to hand.

[Update]: I found an easier way, which was to create the zip file with a temporary name, and rename it with an Exec task:
rename @(ZipFile) "Daily Build %Date:~6,4%-%Date:~3,2%-%Date:~0,2% %Time:~0,2%-%Time:~3,2%-%Time:~6,2%.zip"
Other than that, using MSBuild for the build machine is pretty successful. As with any new technology, the documentation is sparse, but I've got it to get the latest code out of SourceSafe, build it and run the NUnit tests in the debug assemblies (having excluded the test code from the release versions).

Not wanting to ask my boss for lava lamps (or as they should have called them, java lamps), I put a monitor by the door which will show a kiosk mode browser with either a green or red background depending on the latest build's success. It is just as visible.

This is the first time I've used a build machine, and I'm looking forward to seeing how successful it is.
15 March 2005