How to enable logging verbosity process parameter in build definition?
Verbosity for a build will help us to debug the build results to see what exactly went into build. In TFS 2013, default build process template TfvcTemplate.12.xaml verbosity level is set to “Normal” by default and if we need to change the verbosity level we have to download and open the template and set the Verbosity property value of RunMsBuild activity to Detailed or Diagnostic or Minimal (Figure 1.1) and then check-in to TFS and then upload it to build.
Figure 1.1
But this change will be applicable for all the build definitions which makes use of this build template. So we cannot maintain different verbosity levels for all build definitions. And if we observe the default build process template (TfvcTemplate.12.xaml) of TFS 2013, we will not find the logging verbosity parameter to set it to Minimal, Normal, Detailed or Diagnostic. (This option is available in TFS 2012 or TFS 2010 build templates by default). So let’s see how to achieve this by little customization to the template.
Steps to enable the logging Verbosity parameter in Build definition process tab.
- Download the template TfvcTemplate.12.xaml from build definition wizard and add it to the version control folder.
- Now open this file in Visual Studio and you can see the workflow defined for TfvcTemplate.12.xaml template. Click on Arguments tab down the page and create new argument called Verbosity.
- Let the argument Direction be “In” and change argument type to “Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity”. And set Default value as “Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal” as shown in Figure 1.2.
Figure 1.2
- This completes defining the build argument and setting its default value. Now let’s make this argument be available in build definition Process Tab. For this, click on Metadata argument in the argument tab and click on the ellipses (…) button under default value column of Metadata argument as shown in Figure 1.3. This will open “Process Parameter Metadata Editor” window as shown in Figure 1.4
Figure 1.3
Figure 1.4
- In “Process Parameter Metadata Editor” window we can add the parameter that has to be appear in build definition process parameters Figure 1.5.
Figure 1.5
- Let us add the parameter Logging verbosity parameter under category 2. Build after 5. Advanced parameter i.e. 6. Logging verbosity.
To do this, open” Process Parameter Metadata Editor” and make note of parameter ProjectsToBuild, because we are adding parameter under same category. Image 1.5, in our template category value is #200 Build
Figure 1.6
Now click on Add button and give following details as shown in Figure 1.7..
Parameter Name | Verbosity |
Display Name | 6. Logging verbosity |
Category | #200 Build |
Description | Specify the level of logging desired for this build. Higher verbosity levels will typically result in slower builds. |
Value Format String | Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity |
View this parameter when | Always show the parameter |
- Where Parameter Name should be same as argument name defined (Step 2), Display Name depends on how you want to display this parameter in build definition, Category under which category you want to display the parameter, Description explains the parameter in build definition and View this parameter when for enabling this parameter either only in build definition or only when queuing the build or both in definition and queuing the build or never.
Figure 1.7
- After entering the details click ok and save the changes then check-in the template to Source Control. Use this customized template in build definition and you will be able to see the new parameter logging verbosity as shown in Figure 1.8, or while queuing you can edit this verbosity value in queue build parameter window as shown in Figure 1.9
Figure 1.8
Figure 1.9
Thank you for reading this blog post, your comments are always welcome.