TFS 2010 – Ordering the Build Process Parameters On The Definition
So, I had someone ask this question about the process parameters on the Process tab of the Build Definition Editor - “How can I get the Advanced category above the Basic category?” I decided it would be better to share this with everyone, since it isn’t documented anywhere.
The first thing to note is that a property grid does not allow custom sorting of categories. They are always in alphanumeric order. However, we get around this by numbering the categories. This allows us to sort them, but we don’t sort them by name. We sort them by priority. What priority? Let me show you what I mean.
If you open the defaultTemplate.XAML file in the editor and click on the Arguments button to show the top level parameters, you will see a property called “Metadata”. This property can be used to override the meta data that we have on the process parameters. You would also want to use this property to set the meta data for any custom process parameters – see this post for more info.
Under the “Default value” column click the “…” button to edit the Metadata. Unfortunately, we don’t populate this with the default values. You have to know them (luckily I can simply look back at the source code :).
Here is what you see…
Notice the category field. If you add a new parameter (with the same name as an existing parameter) you can set the metadata properties. I chose to modify the Agent Settings process parameter. I set all the metadata to exactly what we set it to in code, so there shouldn’t be any differences when I run it.
Here’s what that looks like…
When I check it in and open the definition, the process parameters are all exactly the same as before. So, where is this “category priority”. Well, I actually lied before. The category in the picture above is NOT the category string that we use. The category string we use is actually “#300 Advanced” The ‘#’ at the front tells the code that the first part of the string is a priority number. Notice that we use 300 here. Required is 100, Basic is 200, and Advanced is 300. That allows space for you to put your own categories before or in between ours.
So, what do you think happens if I change the Category to “#150 Advanced”?
After saving and checking the change in, I get the following order when I look at the process parameters:
Since I changed the priority for the Advanced category on Agent Settings, that value was used instead of the default value of 300. Thus, the entire category was moved above the Basic category.
Now, we automatically collapse any section named “Advanced” so this won’t fix that problem, but it does show you that you can move the categories around and put your own categories before ours.
Happy coding!
Comments
Anonymous
November 07, 2011
Almost a year on and this was exactly what I needed, thanks :)Anonymous
March 09, 2012
How Can we do this using API'sAnonymous
March 11, 2012
You don't need any APIs. All I am doing above is updating the text in the XAML. It's just text, so you could simply update the XAML directly or with some custom tool. Follow the steps above and look at the diff of the XAML file after the changes.Anonymous
March 15, 2012
It does not work correct if you have more then 9 categories, e.g. 11 categories:
- Required
- Some category
- Another category
- Basic
- Advanced ...
Anonymous
March 19, 2012
That is exactly right. The ordering is AlphaNumeric. So, 10 comes before 2. You can fix this by specifying 2 digits in all the categories. But, I would argue that 10 categories is way too many. One of the reasons that we have 3 built-in categories is that we felt 3 was enough.Anonymous
March 20, 2012
Where can I specify the 2 digit numbering?Anonymous
August 07, 2012
Hi Jason, Can you indicate the procedure for the 2 digits numbering? unfortunatly i have more than 10, agreed that it is allot, but fact. Any clarification is highly appreciated! Thanks!Anonymous
August 07, 2012
Hi Jasper and Wiles, I was wrong. There is not a way to specify 2 digits in the number format. Sorry for the bad information. I will try to fix this bug in our code so that it prefixes the Categories with zeros if needed. Thanks for letting me know about the problem. JasonAnonymous
September 04, 2012
Do you happen to know if there is a way to initially collapse a category? We have some optional build arguments that I'd like to show collapsed/hidden and was curious if this is possible (similar to how the Advanced section is initially collapsed). :) Thanks in advance for any suggestions, AnthonyAnonymous
September 17, 2012
Unfortunately, we don't provide a way to do that. Unless, of course, it is named "Advanced". We look for that name and collapse that section. JasonAnonymous
February 13, 2013
Is this Process Parameter Metadata Editor missing in VS 2012? >> "Under the “Default value” column click the “…” button" This "..." button does not exist. There is a "..." button in the properties window, but it just brings up the expression editor.Anonymous
February 13, 2013
Hi James, This isn't what you want to hear, but it works for me :( you can edit the Metadata directly in the XAML by opening it in Notepad or the VS xml editor. If you figure out why it isn't working, please let me know. Thanks, JasonAnonymous
May 09, 2013
The #300 pattern is handled (hidden) if that is in front of the parameter category, however is not hidden if want to order the individual parameters, for instance "#401 Package by Install Shield" is the parameter display name defined in the metadata list, and it is shown as "#401 Package by Install Shield" in the UI. the "#401" was not hidden.Anonymous
May 15, 2013
You are correct. We don't currently have a good way to order the items within the categories. You can put numbers beside them yourself, but I know that's not ideal. JasonAnonymous
August 15, 2013
Echoing James above. I see the elipse button but the main process "categories" aren't there as they were in 2010. I see the parameters that I've setup, but not the main parameters and their display names. Using VS 2012 with Update 2 and the power tools. Any thoughts?Anonymous
September 17, 2013
Hi Joseph, I would compare your XAML file to the default XAML and see if anything jumps out. My only guess would be that somehow the type for Metadata was changed from Property to InArgument. But that's just a guess. Good luck, JasonAnonymous
April 08, 2014
I found this post I long time ago and used it successfully with TFS 2010 and 2012 - worked like a charm. But now I'm working with VS Online. When I attempt to add any custom property to my build template, no matter what I put for the category (I've tried #200 Basic, #300 Advanced, and custom categories), they always get lumped in "4. Misc" at the bottom. Is this feature disabled in the 2013 product family? Is it just not allowed in the hosted instances? Or am I missing something else?