Let say that I want to enable clients to choose specific projects to publish from within a build definition.
I can obviously add a StringList argument to the build, and have users write the server paths of each project they want to publish as a open strings.
This off course leaves much room for errors on the client side, but farther more it just looks unprofessional!
I don’t want to write A custom UIEditor for this purpose for the following reasons: I’m lazy, no time, and most important I know that such a control exits!! I mean the control that enables us to choose which projects we want to compile as part of the build!
So now that I see that Microsoft is already using what I need all I have to do is find it and utilize it for my own use:
1) I will go to the arguments tab in the build definition template (possibly DefaultTemplate.xaml) and check what is the type of the variable that is using this UIEditor that I am after. In this case it is “Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings”.
2) In our case this is actually not the type that I am looking for because this type contains both project and configurations, and I need only the Projects’ property type. By typing “new Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings().ProjectsToBuild” you can see the type of the property is “StringList”.
3) I will create my own argument and set it to the desired type (since I’m looking for to using the same type of data. In this case a list of strings containing the Server Paths of Projects), and name it “ProjectsToPublish”.
4) Now, this part is a bit tricky – I will open “Reflector” and in it open the assembly in which the type I found (BuildSettings) is defined (Microsoft.TeamFoundation.Build.Workflow.Activities).
–If you don’t know where the assembly is, do a general search on your pc–
5) Then I will check out the “Editor” attribute of the property “ProjectsToBuild” of the type “BuildSettings”. in this case – "Microsoft.TeamFoundation.Build.Controls.BuildProjectListEditor, Microsoft.TeamFoundation.Build.Controls"
6) At this point I will Edit the “Metadata” argument:
and get this window:
7) In the window I will add my new argument as a Process Parameter, and simply copy the editor’s name (that I found with the reflector) to the Editor textbox.
8) Save and check in the build template file.
9) Go to the “Process” tab of your build definition and press the “Refresh” button to refresh the build definition template.
That was easy, wasn’t it?
Notice that the editor class we are using is internal, and still it is not a problem!