Debugging Azure DevOps

Debugging Azure DevOps

and the .NET Core Test Runner

A couple of quick ways of debugging your .NET DevOps pipeline that you may find useful:

Task Parameters

A handy debug idea is to look at the docs for the tasks in your pipeline, and add to their arguments to produce more verbose output. This has the benefit of being tailored to the specific task you're debugging.

For example, dotnet test has a --verbosity option, which you can set to q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (see the docs). The default is minimal, so this can be helpful in determining issues with the task itself. Beware that detailed and diagnostic can produce thousands of lines of output!

System.Debug and system diagnostics

If you choose to run a pipeline manually, you may have seen the option Enable system diagnostics: image.png

Enabling this will produce lots of debug output regarding the tasks, runners, and agents, which will enable you to debug the pipeline infrastructure.

Variables

If you find it useful, you can enable this all the time (including automatic builds) by adding a variable to your azure-pipelines.yml file:

variables:
  solution: '**/*.sln'
  project: '**/Vapour.Ware.Api.csproj'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  System.Debug: true

Note that many tasks also support variables, so you can apply System.Debug selectively to those tasks instead of the whole pipeline. In this case, I would recommend creating a pipeline variable, which will allow you to manually run the pipeline with the debug option for specific tasks only. To do this:

  1. At the top-right of your web-based pipeline editor, you will see a Variables button: image.png

  2. Select New Variable or click the + button if you already have variables

  3. give it a name, such as selectiveDebug
  4. create the default value of false
  5. select Let users override this value when running this pipeline
  6. now add this to your desired jobs:
    jobs:
    - deployment: deploy_api
     displayName: Deploy Vapour Ware API
     variables:
       System.Debug: '$(selectiveDebug)'
    
    And now when you manually run a pipeline, you can choose to enable debugging for those jobs only without editing your yaml.

What other debugging options do you use? Comment and let me know!