# Debugging Azure DevOps

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](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test)). 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658318200757/M-xFex5po.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658318605129/Lc6zMewXN.png align="left")

1. Select New Variable or click the + button if you already have variables
1. give it a name, such as selectiveDebug
1. create the default value of `false`
1. select *Let users override this value when running this pipeline*
1. 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!
