Tfs build 2010-create a personalized build

In several posts of the past I dealt with customization of TFS 2010 build, but I never pointed out how to create a personalized build that can be used without always resorting to edit the workflow directly. Suppose you work heavily with database projects, and you need to deploy database project to different server in most of your builds. In this scenario each time you need to deploy a DB project you can create a new build process, edit it, add some customization and finally save and use it for the build.

This way to proceed is quite annoying, especially if you need to use custom build actions inside the build, and finally you will end with a customized workflow for each build. In this situation there is a better way to structure your builds. First of all copy the default build workflow and rename it:

SNAGHTML1ba3d94

Figure 1: Copy default workflow

Now edit the workflow and add all the arguments  needed to deploy the database.

SNAGHTML1bbd2e1

Figure 2: Add arguments to the new workflow, add all the argument needed to deploy a database project

Now thanks to Metadata I’m able to configure those arguments to give a better user experience, assigning a Category and descriptions to Arguments.

SNAGHTML1be69f1

Figure 3: Add Metadata to configure all the arguments

Now I drop a DeployDatabase Activity inside the workflow, and use those four arguments to configure it.

SNAGHTML1c231e1

Figure 4: Configure all properties of the Custom Action with the arguments previously declared (Figure 2)

Now I have a customized workflow, inside that workflow I’ve deployed a custom Activity, and finally I’ve declared arguments with metadata used to pass properties to the custom Activity. Now I can create a new Build, choose  DefaultWithDeployDatabase workflow and all the parameters are now exposed directly without the need to edit the workflow.

SNAGHTML1cc0b10

SNAGHTML1c6180b

Figure 5: Use the new workflow in a build.

The important stuff is that you can use modified workflow for several builds, because it can be reused.

Alk.