# .NET project

Before starting, read [Azure Pipelines integration overview](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/azure-pipelines-integration-overview.md).

Once you have [Creating and configuring your project](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/creating-your-project.md) and [Setting up project integration](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/setting-up-project-integration.md), you can add the SonarQube Server analysis to your Azure build pipeline.

To create your Azure build pipeline, you can use either YAML or the Azure Classic interface.

{% hint style="info" %}

* The use of the Classic interface is not always possible (e.g. if your code is stored on GitHub).
* If you use YAML, SonarSource can provide you with YAML templates or code examples.
  {% endhint %}

If you need to use a specific scanner version, see [Using various features](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/various-features.md).

## About the analysis parameter setup <a href="#analysis-parameters" id="analysis-parameters"></a>

Analysis parameters can be set at different levels: see **Configuring the project analysis parameters** in [Setting up project integration](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/setting-up-project-integration.md)**.** When creating your pipeline, you will have to enter the project key and you may also enter the project version and name (For more information about these task inputs, see the **.NET mode** in the [SonarQube tasks for Azure Pipelines](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks.md).). You may define additional parameters in this task. In that case, these parameters have precedence over parameters defined at the project or global level.

## Using YAML <a href="#yaml-pipeline" id="yaml-pipeline"></a>

Add the following SonarQube tasks to your YAML pipeline:

1. Before your build task, add a Prepare Analysis Configuration task.
2. After your build task, add a Run Code Analysis task.
3. After the Run Code Analysis task, add a Publish Quality Gate Result task.

See the YAML file example below. See also our [YAML pipeline templates](https://github.com/SonarSource/sonar-scanner-azdo/tree/master/its/fixtures). For information about the SonarQube task inputs, see [SonarQube tasks for Azure Pipelines](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks.md).

{% hint style="info" %}
Make sure the SonarQube task version used in your YAML file is the correct one.\
For example, in `SonarQubePrepare@7`, `7` should correspond to the version of the [Azure DevOps Extension](/sonarqube-server/2025.2/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops.md) you’re using.
{% endhint %}

<details>

<summary>YAML file example</summary>

```css-79elbk
trigger:
- master # or the name of your main branch
- feature/*

steps:
 # Checkout the repository 
- checkout: self

 # Disable shallow fetch
  fetchDepth: 0

# Prepare Analysis Configuration task
- task: SonarQubePrepare@7
  inputs:
    SonarQube: '<YourSonarqubeServerEndpoint>'
    scannerMode: 'dotnet'
    projectKey: '<YourProjectKey>'

# Dotnet build task
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'

# Run Code Analysis task
- task: SonarQubeAnalyze@7

# Publish Quality Gate Result task
- task: SonarQubePublish@7
  inputs:
    pollingTimeoutSec: '300'
```

</details>

## Using the Classic interface <a href="#classic-pipeline" id="classic-pipeline"></a>

To add the analysis to your classic build pipeline:

1. In Azure DevOps Classic interface editor, create or update your build pipeline.
2. Add a **Prepare Analysis Configuration** task before your build task:
   * In **SonarQube Server Service Endpoint**, select the SonarQube Server service connection you created in **Adding the SonarQube service connection to your AzDO project** in [Setting up project integration](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/setting-up-project-integration.md).
   * Under **Choose a way to run the analysis**, select **Integrate with MSBuild**.
   * In the **Project key** field, enter your project key.
   * Optionally, enter the project name and version.
3. Add a new **Run Code Analysis** task after your build task.
4. Add a new **Publish quality gate Result** on your build pipeline summary.
5. Ensure that the pipeline runs automatically for all the branches you want:
   * Under the **Triggers** tab of your pipeline, select **Enable continuous integration** and select all the branches for which you want SonarQube Server analysis to run automatically.
6. Save your pipeline.

## .Net guides on the Sonar Community forum <a href="#dotnet-community-guides" id="dotnet-community-guides"></a>

We’ve prepared some guides on the Community Forum to help you with your .NET project.

### .NET Configuration <a href="#net-configuration" id="net-configuration"></a>

* [Configuration of WarningAsErrors for .NET build](https://community.sonarsource.com/t/configuration-of-warningsaserrors-for-net-build/32393)
* [Investigating the performance of .NET analysis](https://community.sonarsource.com/t/the-sonar-guide-for-investigating-the-performance-of-net-analysis/47279)

### .NET and Code coverage <a href="#net-and-code-coverage" id="net-and-code-coverage"></a>

* [Generate reports for C# and VB.net](https://community.sonarsource.com/t/coverage-test-data-generate-reports-for-c-vb-net/9871)
* [How to find logs about importing code coverage](https://community.sonarsource.com/t/how-to-find-logs-about-importing-code-coverage/73317)
* [Troubleshooting guide for .NET Code coverage import](https://community.sonarsource.com/t/coverage-troubleshooting-guide-for-net-code-coverage-import/37151)

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

* [Gradle or Maven project](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/gradle-or-maven-project.md)
* [C family project](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/c-family-project.md)
* [JS, TS, Go, Python, PHP, etc. project](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/js-ts-go-python-php.md)
* [Using various features](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/various-features.md)
* [SonarQube tasks for Azure Pipelines](/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks.md)
* [Overview](/sonarqube-server/2025.2/analyzing-source-code/dotnet-environments/overview.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.2/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/dotnet-project.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
