# Using various features

This section explains features you may use when adding SonarQube analysis to your Azure build pipeline:

* Choosing the analysis configuration mode (only in the Standalone SonarScanner CLI mode).
* Using a specific version of the SonarScanner for .NET or CLI
* Using the cache feature

## Choosing the configuration mode <a href="#configuration-mode" id="configuration-mode"></a>

In the CLI mode of the Azure DevOps extension for SonarQube Server, you may:

* Either use the file configuration mode (default mode) which consists of setting analysis parameters in the `sonar-project.properties` file stored in the repository root (or another specified configuration file).
* Or use the manual configuration mode to define analysis parameters at the pipeline level. In that case, the scanner doesn’t check the `sonar-project.properties` file.

See also **Configuring the project analysis parameters** in [creating-your-project](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/creating-your-project "mention").

<details>

<summary>Using the file configuration mode</summary>

The file configuration mode is the default mode of the Azure DevOps extension for SonarQube.

**YAML pipeline**

1. Make sure the `configMode` input of the `SonarQubePrepare` task is set to `file`.
2. To use a different configuration file than `sonar-project.properties`, add the `configFile` task input to the `SonarQubePrepare` task, with the path to the configuration file as the value. The path can be absolute, or relative to the repository root.

**Classic pipeline**

In the Prepare Analysis Configuration task:

1. Make sure the **Store configuration with my source code** mode is selected.
2. In **Settings file**, you can define a different configuration file than `sonar-project.properties`. The path can be absolute, or relative to the repository root.

<div align="left"><figure><img src="https://3577027091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69lEOGGgOhCpumODGD9v%2Fuploads%2Fgit-blob-eb685105ca7b6e7bbf0045ed4d093fef32f63767%2Fsonarqube-azure-pipelines-file-mode.png?alt=media" alt="Select Store configuration with my source code" width="291"><figcaption></figcaption></figure></div>

</details>

<details>

<summary>Using the manual configuration mode</summary>

To define analysis parameters at the pipeline level in Standalone SonarScanner CLI mode, proceed as described below.

**YAML pipeline**

1. Make sure the `configMode` task input in the `SonarQubePrepare task` is set to `manual`.
2. Use the `extraProperties` task input in the `SonarQubePrepare task` to define the analysis parameters: define a new sonar property by adding `<propertyKey>=<propertyValue>` on a new line.

**Classic pipeline**

In the Prepare Analysis Configuration task:

1\. Select the **Manually provide configuration** mode and enter the required parameters.

<div align="left"><figure><img src="https://3577027091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69lEOGGgOhCpumODGD9v%2Fuploads%2Fgit-blob-58ecc2f517ce36105f863b7b4fa875714a8a35bb%2Fsonarqube-azure-pipelines-manual-configuration-mode.png?alt=media" alt="Select the Manually provide configuration mode" width="302"><figcaption></figcaption></figure></div>

2\. In **Advanced section** > **Additional properties**, define a new sonar property by adding `<propertyKey>=<propertyValue>` on a new line.\
**Example**: `sonar.exclusions=**/*.bin`

</details>

## Using a specific version of SonarScanner for .NET or CLI <a href="#specific-scanner-version" id="specific-scanner-version"></a>

The Azure DevOps extension for SonarQube Server embeds the latest compatible version of the SonarScanner for .NET and SonarScanner CLI. In very particular situations, you may want to use another scanner version. In such a case, you can configure the download of this specific version from the SonarSource binaries site. In addition, you can use the Azure cache task(see below) in your pipeline to manage the caching of the SonarScanner.

The figure below shows the download process of a specific version of SonarScanner for .NET or SonarScanner CLI.

<figure><img src="https://3577027091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69lEOGGgOhCpumODGD9v%2Fuploads%2Fgit-blob-2f955565bac6c087d893786b9e07c53015d8e2a9%2Fsonarqube-azure-devops-specific-dotnet-or-cli-scanner-version.png?alt=media" alt="Download process of a specific version of SonarScanner for .NET or SonarScanner CLI"><figcaption></figcaption></figure>

Set up the download in the Prepare Analysis Configuration task of your pipeline as described below.

<details>

<summary>SonarScanner for .NET</summary>

You must specify the full version number, such as 8.0.3.99785 (and not 8.0.3). All of the available version numbers can be found [here](https://github.com/SonarSource/sonar-scanner-msbuild/tags).

**YAML pipeline**

Add the following input to the Prepare Analysis Configuration task:

* `dotnetScannerVersion`: The SonarScanner for .NET version to be downloaded.

The code snippet below shows a task configuration example. For more information about the task inputs, see [sonarqube-tasks](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks "mention").

```css-79elbk
- task: SonarQubePrepare@7

  inputs:

    SonarQube: '<YourSonarqubeServerEndpoint>'

    scannerMode: 'dotnet'

    dotnetScannerVersion: '8.0.3.99785'

    projectKey: '<YourProjectKey>'
```

**Classic pipeline**

In **Scanner Version**, enter the version to be downloaded.

</details>

<details>

<summary>SonarScanner CLI</summary>

You must specify the full version number, such as 6.0.0.4432 (and not 6.0.0). All of the available version numbers can be found [here](https://github.com/SonarSource/sonar-scanner-cli/tags).

**YAML pipeline**

Add the following input to the Prepare Analysis Configuration task

* `cliScannerVersion`: The SonarScanner CLI version to be downloaded.

The code snippet below shows a task configuration example. For more information about the task inputs, see [sonarqube-tasks](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks "mention").

```css-79elbk
- task: SonarQubePrepare@7

  inputs:

    SonarQube: '<YourSonarqubeServerEndpoint>'

    scannerMode: 'cli'

    configMode: 'file'
    configFile: 'my-config.properties'    

    cliScannerVersion: '6.0.0.4432'

    cliProjectKey: '<YourProjectKey>'

    cliSources: '.' 
```

**Classic pipeline**

In **Scanner CLI Version**, enter the version to be downloaded.

<div align="left"><figure><img src="https://3577027091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69lEOGGgOhCpumODGD9v%2Fuploads%2Fgit-blob-978416714cc64f491c59b6b31fe28490ac9fea1a%2Fsonarqube-azure-devops-download-specific-scanner-version.png?alt=media" alt="Select Use Standalone SonarScanner CLI for the analysis" width="501"><figcaption></figcaption></figure></div>

</details>

## Using the cache feature <a href="#cache-feature" id="cache-feature"></a>

Azure DevOps allows [pipeline caching](https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops) to improve build performance by facilitating the download of dependencies between pipeline runs. Currently, you can only cache the SonarScanner (bootstrapper) that is downloaded when you need a specific version of SonarScanner for .NET or CLI.

Proceed as follows:

* Add a [cache task](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/cache-v2?view=azure-pipelines) to your Azure build pipeline before SonarQube’s **Prepare Analysis Configuration** task. See the code snippet below according to the extension mode.

<details>

<summary>.NET</summary>

```css-79elbk
- task: Cache@2

  displayName: Cache SonarScanner

  inputs:

    key: '"SonarScanner" | ".NET" | "$(Agent.OS)"'

    path: '$(Agent.ToolsDirectory)/SonarScanner .NET'
```

</details>

<details>

<summary>CLI</summary>

```css-79elbk
- task: Cache@2

  displayName: Cache SonarScanner

  inputs:

    key: '"SonarScanner" | "CLI" | "$(Agent.OS)"'

    path: '$(Agent.ToolsDirectory)/SonarScanner CLI'
```

</details>

## Disable comments in your pull requests

If you want to decorate your pull request with a quality gate status and are not interested to have SonarQube Server annotations in your PR, see the [#disable-pull-request-annotations](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/setting-up-project-integration#disable-pull-request-annotations "mention") article.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [gradle-or-maven-project](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/gradle-or-maven-project "mention")
* [dotnet-project](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/dotnet-project "mention")
* [c-family-project](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/c-family-project "mention")
* [js-ts-go-python-php](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/js-ts-go-python-php "mention")
* [sonarqube-tasks](https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks "mention")
