Team Foundation Build: Enhancing the experience with built-in custom editors
bi
When designing or customizing a Team Foundation Build process template you may have parameters that are not as basic as an integer or a string. You may want to provide your user with a nice UI to edit the values either when designing the build process template (for defining custom values for example) or queuing the build (in cases where the parameter can be defined/overridden when the build is queued).
Even when the parameters are of primitive types defined by .Net, you may want to provide a nice editor that allows easier editing for a parameter that doesn’t have a simple syntax. One example is the Team Foundation Build built-in Build Number Format ****editor.
Image 1: BuildNumber format Editor
While writing such an editor is easy, (I will not go into such details since Jason Prickett has already done a great post about it.
While writing this kind of integration is pretty easy writing the UI for object may be a somewhat tedious and long task. For example you want to reference objects stored inside TFS like a file stored in source writing the navigation can take some time.
This was exactly the situation I faced recently; designing a complex process template in which I have (among many others) two parameters which reference a path and a file in source control.
While power users don’t mind entering $/MyTeamProject/MyProject/Trunk/ in a text box, it’s not something a regular user would want to do.
While writing the glue to Team Foundation Build is easy, writing a source control folder picker like Browser for Folder requires some work.
Image 2: Browser for Folder
I would rather spend my time providing business value than writing plumbing. Since Microsoft obviously already has some code in place it would likely just be a matter of leveraging that.
There were basically two possibilities:
- The browser picker UI is publically available and we just have to write a few lines of gluing code to integrate it with the Team Foundation Build user experience
- Microsoft provides a publically accessible designer so we can just use it without having to write a single line of code.
Alas, none of these options appears to be available.
While 1) is available with some reflection hacking (see this post from Mathias Olausson)
Option two is preferred (no code is always better than some code )
Not all is lost however; there is no publically available designer but there is an internal one (which means it may change in the next version but highly unlikely)
Luckily, they are implemented in Microsoft.TeamFoundation.Build.Controls assembly, which is where the UI for the builds is also stored. So we can freely reference it the Editor Parameter in the Metadata argument to enhance our user experience. (see Jason Prickett’s post on how to do this)
So just enter Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls in the editor parameter and everything is set.
Image 3: Editing the Editor parameter to specify the custom designer
When editing the build definition (or queuing if the parameter can be defined/overridden while queuing) the parameter will have an ellipsis button
Image 4: Ellipsis Available to use
Upon clicking on the button you will be presented with the dialog
Image 5: Browser Dialog
Not bad for something that takes 15 seconds to implement and greatly enhances the user experience.
Other designers included in the same assembly, that you can leverage to improve the user experience
Editor (namespace ommited) |
BuildAgentSelectionEditor |
BuildProjectListEditor |
ServerFileBrowserEditor |
TestSpecEditor |
WorkItemTypeSelectionEditor |
ServerFolderBrowserEditor |
StringListEditor |
EnumPropertyEditor |