From time to time, I have to run batch files to perform some cleanup or restore jobs on CI servers.
Usually this is as simple as logging into the remote server and manually launching a batch file. But what about automating this process a little bit and using TFS to launch scripts?
Currently I use TFS 2010, but this approach will also work with the 2012 and 2013 versions of TFS.
In order to do this, a new build definition must be created along with a template that has a few activities. After this, the batch file will be able to run on the build server using the TFS setup. The results will then be seen in the Build Details window.

Build Template Creation
To get an empty template, I’ve taken DefaultTemplate.xaml (the default template in the TFS build system) and deleted all default activities using a graphic designer.
Continue reading →