Getting started with NDepend Azure DevOps extensions
Tags: ndepend, azuredevops, azure, dotnet
Published: 2022-08-28 13:06:00

Hello, everyone! I will share with you my experience with [Code Quality NDepend for Azure DevOps](https://marketplace.visualstudio.com/items?itemName=ndepend.ndependextension). Please make sure you've set up/installed the extension to your Azure DevOps server.

* After you installed the extension, you will need to set up the licenses. Please navigate to any of your Azure DevOps projects and click on the NDepend menu.

![NDepend Menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1k6yu2ie0yzmezg4m8b.png)

* After you've set up the licenses, you need to set up the users.

![users](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gqy795gzbpt66313xvrv.png)

* You will need to set up the dashboard too. For me, I will choose all options.
 
![options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tt5j30rrd0hn9x81nu0w.png)


## NDepend Tasks

If you want to store the artifacts about the code quality scans, you will need to add NDepend Tasks. I will give you small job setups, so you will have the code quality results.

```yaml
- job: "CodeQuality"
  pool:
    vmImage: "windows-2022"
  steps:
  - task: UseDotNet@2
    displayName: 'Use .NET Core SDK $(dotnetSdkVersion)'
    inputs:
      version: '$(dotnetSdkVersion)'
      includePreviewVersions: true
  - task: DotNetCoreCLI@2
    displayName: 'Restore project dependencies'
    inputs:
      command: 'restore'
      projects: '**/*.csproj'
  - task: DotNetCoreCLI@2
    displayName: 'Build the project - $(buildConfiguration)'
    inputs:
      command: 'build'
      arguments: '--no-restore --configuration $(buildConfiguration)'
      projects: '**/*.csproj'
  - task: DotNetCoreCLI@2
    displayName: 'Run unit tests - $(buildConfiguration)'
    inputs:
      command: 'test'
      arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
      publishTestResults: true
      projects: '**/*.Test.csproj'
  - task: NDependTask@1
    env:
      SYSTEM_ACCESSTOKEN: $(system.accesstoken)
```

* Important lines:

* `vmImage: "windows-2022"`. You will need this line, since currently `NDependTask` only supports windows OS.

* You will need an environment for `NDependTask`. You will need the environment SYSTEM_ACCESSTOKEN so your `NDependTask` may upload your results to the build artifacts.

```yaml
env:
  SYSTEM_ACCESSTOKEN: $(system.accesstoken)
```

* In summary, your jobs will be like this.

![Task flows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hv9nlx5dwiqcgo4wcrcc.jpg)

## Exploring the NDepend extensions

In your build results, you may see the result like this.

![Build Results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08orphr8jkecbygc5981.png)

You may get the summary of the NDepend tasks in the dashboard. I haven't set up the code coverage yet, that's why it's now shown up in my dashboard.

![dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8x7zwxuv6h5tf79dhxat.png)

You can navigate to the Issues/Debt tab for more details about the Issues.

![Issues](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duwt185ymm3fg32b70np.png)

One of my favorite features is Trend. I can see and track the changes of my `% Debt`.

![Trend](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce8pmoyia6gfh5e8l1fv.png)
 
## Thank you

Thanks for reading. So, do you want to try it? You may use the trial versions if you want to try the extension. What are you waiting for? Grab it now and share your experiences. If you have more questions, you may comment here.

![Thanks GIF](https://media.giphy.com/media/2OHYMJGnGoiVjVg55P/giphy.gif)