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…

image

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…

image

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:

image

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!