.NET project with Azure Pipelines
Using YAML or the Azure Classic editor to create the Azure build pipeline for .Net projects.
The setup is different depending on whether you use YAML or the Azure Classic interface.
Before you start
Before you begin, read About Azure Pipelines integration.
The prerequisites are:
The Azure DevOps Extension is installed in your Azure DevOps organization: see Azure DevOps Extension.
Your project is created in SonarQube Server (see Importing your Azure DevOps repository) and configured for Azure Pipelines (see Setting up Azure integration for your project).
The pull request and branch analysis are enabled in your pipeline.
If you need to use a specific scanner version, see Using Azure DevOps extension's features.
Using YAML
Add the following SonarQube tasks to your YAML pipeline:
Before your build task, add a Prepare Analysis Configuration task.
After your build task, add a Run Code Analysis task.
After the Run Code Analysis task, add a Publish Quality Gate Result task.
See the YAML file example below. Also, see the YAML pipeline templates. For information about the SonarQube task inputs, see SonarQube tasks for Azure Pipelines.
Using the Classic editor
To add the analysis to your classic build pipeline:
In the Azure DevOps Classic editor, create or update your build pipeline.
Add a Prepare Analysis Configuration task before your build task:
In SonarQube Server Service Endpoint, select the SonarQube service connection you created during setup. See the Setting up Azure integration for your project page for more information about adding a connection.
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.
Add a new Run Code Analysis task after your build task.
Add a new Publish quality gate Result on your build pipeline summary.
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.
Save your pipeline.
Configuring your scanner
If you're using the .NET scanner to complete the analysis, see the Configuring the scanner for NET page for language-specific details.
There's also an article about running Multi-language analysis for select languages when the sonar.scanner.scanAll parameter is enabled via the extraProperties listed in your Prepare Analysis Configuration task.
There's also an article about running Prepare Analysis Configuration task.
.Net guides on the Sonar Community forum
We’ve prepared some guides on the Community Forum to help you with your .NET project.
.NET Configuration
.NET and Code coverage
Related pages
Using Azure DevOps extension's features when adding the analysis to your pipeline
Overview of .NET analysis
Was this helpful?

