Mathias Olausson [MVP]

How to add an enum to a TFS build definition

without comments

Recently I was asked how you go about to create an enum/drow-down argument in a TFS build definition. It’s actually a quite easy thing to solve and requires very little code. But it does require a fair bit of plumbing and since I didn’t find an example on how to do this I’m posting the steps here.

This is the scenario: I want a drop-down argument in my build definition that’s bound to an enum value, i.e. let me select the build status from a known set of values:


First add an enum to a TFS build activity:


I’m assuming you’re familiar with the process of TFS build extensibility. If you need an example of how to create a TFS build activity see for an example.

Next add an argument of the BuildStatusEnum type to your build definition:


To get the enum to show as drop-down you need to add metadata to render it correctly. Open the metadata editor in from the Metadata argument and add the BuildStatus argument as a parameter. Then specify Microsoft.TeamFoundation.Build.Controls.EnumPropertyEditor, Microsoft.TeamFoundation.Build.Controls as the Editor, this does the trick of rendering the enum as a drop-down in the build definition process later on. The EnumPropertyEditor is one of the built-in editors which is convenient to use instead of implementing this logic yourself. If you’re curious of what other editors there are then take a look at this post and dig deeper by using a .NET reflection tool to investigate the code.


That’s all you need to do to setup the design time experience, now you can go on and use the enum in the build definition as you intend to.


Written by Mathias Olausson

June 30th, 2014 at 6:59 am

Posted in Uncategorized

Leave a Reply