Last week I wrote about how you can make use of PowerShell to log extended diagnostics information when running a build. The two examples I included showed you how to collect environment variable information (e.g. names and values) as well as list (recursively) folders and files beneath a specified folder. As an additional exercise, I decided to convert these two examples to build tasks and publish them as the VSTS-Tools extensions.
The VSTS-Tools extensions currently includes two build tasks:
- VSTS-List Files
- VSTS-List Variables
VSTS-List Files
This extension will list out (in the log) all files beneath the folder specified as the Root Folder. There are two parameters that can be set with this task:
- Root Directory – all files and folders beneath the root directory will be listed (recursively).
- Execute on Debug Only – if checked, the task will execute only if system.debug is set to true.
VSTS-List Variables
This extension will list out (in the log) all variables that are defined at the time this extension is executed. There is one parameter that can be set with this task:
- Execute on Debug Only – if checked, the task will execute only if system.debug is set to true.
After adding either of these tasks to your build definition and running a build you will find the results in the log for the related task.
While these tasks are especially useful for diagnosing builds on hosted build agents, where you do not have direct access to interrogate the servers, they are also useful for keeping a record of environment variables and file that were present when the build was executed (e.g. in case you open a historical build and are wondering what values existed for specific environment variables at the time).
There are other updates planned for this set of extensions. Check out the road map on the VSTS-Tools Build Extensions page for further details.
As always, if you have any suggestions, please let us know in the comments section below.
Install the VSTS-Tools Build Extensions here.
Also, you can check out the source code on GitHub here.