Sonar properties are not used by Azure Devops

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Azure SonarQubePrepare/Plugin 4.8.0
    SonarQube Community Edition Version 8.0 (build 29455)

  • what are you trying to achieve
    Hello, I am trying to get dotcover code coverage and nunit tests to be part of the sonarqube analysis on an azure devops pipeline.

  • what have you tried so far to achieve this
    I have run tests and code coverage using a powershell script.
    The cobertura converted dotCover results are stored in cobertuta/coverage.xml relative to rootfolder.
    Nunit files are generated as *nunit.dll.xml in different folders.

I tried adding properties to the task in azure

 - task: SonarQubePrepare@4
      SonarQube: '****'
      scannerMode: 'MSBuild'
      projectKey: '***'
      projectName: '***'
      extraProperties: |

I also tried adding a file in the root folder of the repository


And I tried setting the same values on the sonarqube server in the project. Tried all at the same time and one by one. But when I run the task it always says no unit tests found and no code coverage found. I also tried adding the cobertura report to the temp directory on the agent but same issue.

2020-01-17T09:52:28.4956920Z ##[section]Starting: SonarQubeAnalyze
2020-01-17T09:52:28.5163227Z ==============================================================================
2020-01-17T09:52:28.5163313Z Task         : Run Code Analysis
2020-01-17T09:52:28.5163356Z Description  : Run scanner and upload the results to the SonarQube server.
2020-01-17T09:52:28.5163403Z Version      : 4.8.0
2020-01-17T09:52:28.5163439Z Author       : sonarsource
2020-01-17T09:52:28.5163492Z Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](
2020-01-17T09:52:28.5163848Z ==============================================================================
2020-01-17T09:52:29.1371027Z [command]E:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2020-01-17T09:52:30.1034460Z SonarScanner for MSBuild 4.7.1
2020-01-17T09:52:30.1035600Z Using the .NET Framework version of the Scanner for MSBuild
2020-01-17T09:52:30.1414338Z Post-processing started.
2020-01-17T09:52:31.0973059Z 10:52:31.096  Fetching code coverage report information from TFS...
2020-01-17T09:52:31.0988253Z 10:52:31.098  Attempting to locate a test results (.trx) file...
2020-01-17T09:52:31.2757152Z 10:52:31.275  Looking for TRX files in: E:\agent\_work\21\TestResults
2020-01-17T09:52:31.2760808Z 10:52:31.275  No test results files found
2020-01-17T09:52:31.4606148Z 10:52:31.46  Did not find any binary coverage files in the expected location.
2020-01-17T09:52:31.4616521Z 10:52:31.461  Falling back on locating coverage files in the agent temp directory.
2020-01-17T09:52:31.4625976Z 10:52:31.462  Searching for coverage files in E:\agent\_work\_temp
2020-01-17T09:52:31.4635987Z 10:52:31.463  No coverage files found in the agent temp directory.
2020-01-17T09:52:33.9421742Z WARNING: File 'E:\agent\_work\21\s\XXXX' does not exist.
2020-01-17T09:52:34.1390048Z Calling the SonarQube Scanner...
2020-01-17T09:52:34.4608295Z INFO: Scanner configuration file: E:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\sonar-scanner-\bin\..\conf\
2020-01-17T09:52:34.4654950Z INFO: Project root configuration file: E:\agent\_work\21\.sonarqube\out\
2020-01-17T09:52:34.6060756Z INFO: SonarQube Scanner
2020-01-17T09:52:34.6061269Z INFO: Java 1.8.0_231 Oracle Corporation (64-bit)
2020-01-17T09:52:34.6061491Z INFO: Windows 10 10.0 amd64
2020-01-17T09:52:35.5222408Z INFO: User cache: C:\Users\admin\.sonar\cache
2020-01-17T09:52:36.2219211Z INFO: SonarQube server 8.0.0
2020-01-17T09:52:36.2233491Z INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
2020-01-17T09:52:36.5969186Z WARN: SonarScanner will require Java 11+ to run starting in SonarQube 8.x
2020-01-17T09:52:36.6935444Z INFO: Load global settings
2020-01-17T09:52:37.4791816Z INFO: Load global settings (done) | time=785ms

Any idea what I am missing?

Can I log the properties of the sonarqube run somehow?

Hi ,

I think that your are mixing somehow the possibilits of the different properties available for tests executions and coverage.

As per the SonarQube doc here are the supported property around C# projects :

For coverage :


For unit test executions (will show the number of unit tests executed / discovered).


Any other provided will be ignored.


Thank you for helping with the correct properties.

Got it working for nunit with this:

        SonarQube: '***'
        scannerMode: 'MSBuild'      
        projectKey: '*'
        projectName: '*'   
        extraProperties: |
          sonar.exclusions=**/*.java, **/*.jar, **/*.xml, 3rdPartyLibraries/**, UIAutomationTesting/**, 
packages/**, CM/**

Now the 1 million dollar question is what dotcover format is compatible with sonarqube?

XML or DetailedXML gives missing <!DOCTYPE HTML error, HTML it cannot find.

For anybody else.

This devops task

  - task: SonarQubePrepare@4
      SonarQube: '**'
      scannerMode: 'MSBuild'      
      projectKey: '*'
      projectName: '*'   
      extraProperties: |
        sonar.exclusions=**/*.java, **/*.jar, **/*.xml, 3rdPartyLibraries/**, UIAutomationTesting/**, packages/**, CM/**

and this dotcover made it work

dotCover.exe analyse /targetexecutable=".\packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe" /targetarguments="UnitTest.dll --result=nunit.dll.xml --noheader" /output=coverage/coverage.html /reporttype=HTML
1 Like

The SonarQube code analysis task in our build pipeline yaml getting failed with below error.

Not sure from where the sonarqube is taking the location from . its taking the users home directory now. /home/vowne. We have enough space in other location and would need to change the sonarqube temp location to there.

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: on project: Unable to load component interface org.sonar.api.utils.TempFolder: Failed to create temporary folder in /home/vowne/.sonar: /home/vowne/.sonar/.sonartmp_xxxxxxx: No space left on device


Any suggestion on the above issue… can we set any additional property in the sonarqube pligin task part to change the temp directory creation from the /home/vowne to /data

- task: SonarQubePrepare@4
      SonarQube: 'Sonarqube'
      ScannerMode: 'Other'
      extraProperties: |
          sonar.projectName=${{ parameters.myName }}