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 http://msdn.microsoft.com/en-us/library/hh850441.aspx 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 http://bartwullems.blogspot.se/2012/07/tfs-build-using-built-in-editors.html 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.