Installing and Configuring DelayedBuildTask
To install the DelayedBuildTask on your build server:
- Create a new folder where the build task files will be stored. By default, this should be: C:\Program Files\MSBuild\DelayedBuildTask. NOTE: If you change this path, you will need to modify the .targets file accordingly.
- Copy the files within the DelayedBuildTask folder from the "Cannot resolve link: [file:Binaries Only|DelayedBuildTask_-_Binaries_Only_v1.zip|]" download into the newly created folder. This folder should consist of four files, including:
- BuildQueuedNotification.html - this is the HTML template used when sending a notification that a build has been queued. This template can be modified based on your team's specific needs.
- BuildStartedNotification.html - this is the HTML template used when sending a notification that a previously queued build has been started. This template can be modified based on your team's specific needs.
- DelayedBuildTask.dll - this is the custom task assembly.
- DelayedBuildTask.targets - this is the custom tasks .targets file. This is the .targets file that will be imported into your build script(s). If you installed the custom build task to a folder other than the default folder listed above, you will need to modify the .targets file to reference the correct folder.
Installing and Configuring DelayedBuildWeb
The DelayedBuildTasks relies on a simple (single-page) web application to provide the ability to cancel a build. The web application consists of a single ASPX page that utilizes the Team Foundation Server Web Services API to cancel a build. To setup the web application:
- Create a folder called DelayedBuildWeb (e.g. C:\Inetpub\wwwroot\DelayedBuildWeb).
- Copy the folders and files within the DelayedBuildWeb folder from the "Binaries Only" download into the newly created folder.
- Within the Web.config file, locate the value http://TFSSERVER:8080/build/v2.0/buildservice.asmx and replace "TFSSERVER:8080" with the address of your Team Foundation Server Application Tier. This is the address of the web services API used to manage builds.
- Within IIS Manager:
- Create an Application Pool and modify it to run under an account that has permissions to your Team Foundation Server (e.g. so that it can cancel builds).
- Convert the DelayedBuildWeb folder to a web application and set the Applicaton Pool to the one created above.
Modifying the Build Script to use DelayedBuildTask
To utilize the DelayedBuildTask within your build script:
- At the top of your TFSBuild.proj file, import the .targets file as follows: <Import Project="$(MSBuildExtensionsPath)\DelayedBuildTask\DelayedBuildTask.targets" />
- Override the desired target within your build script where you would like the delay to begin (and at which point you would like the e-mail notification to be sent out). Typically, this would be the target <BeforeEndToEndIteration>. Here is an example of an overridden target:
<!-- Delay the build and send out an e-mail notification with an option to cancel -->
<Target Name="BeforeEndToEndIteration">
<DelayedBuildTask ToAddress="John.Doe@MyCompany.com"
SmtpServer="mail.MyCompany.com"
BuildUri="$(BuildUri)"
DelayedBuildWebUrl="http://TFSSERVER/DelayedBuildWeb"
BuildProperties="{BuildType}=$(BuildDefinition)|{TeamProject}=$(TeamProject)|{ContactMe}=<a href="mailto:John.Doe@MyCompany.com">John Doe</a>"
Delay="300"
SendSecondaryNotification="true"/>
</Target>
In this example, an e-mail message will be sent when a new build is queued and then a delay of 300 seconds (5 minutes) will occur unless the build is cancelled. See DelayedBuildTask Properties for a list of properties that can be passed into the build task.
|