.net core on azure devops

I am using the Azure Devops integration and have followed all of the steps detailed in your docs, but am getting a error when the analysis tries to run.

I am running on an Azure hosted build agent with the Service Connection setup and a PAT for the PR integration. We are running our builds using the dotnet CLI rather than MsBuild. So possibly this is related to the issue we are seeing. I can’t see anything in the docs that covers this use case though.

I have managed to get some results into the account manually on my local command line using the dotnet-sonarcloud tool, but I don’t want to have to put a access token into the source control and would rather use the extension and service connection for security.

Thanks: Below is the error I see in azure devops.

INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 44.456s
INFO: Final Memory: 7M/27M
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
INFO: ------------------------------------------------------------------------
##[error]ERROR: Not authorized. Please check the properties sonar.login and sonar.password.
ERROR: Not authorized. Please check the properties sonar.login and sonar.password.
##[error]The SonarQube Scanner did not complete successfully
The SonarQube Scanner did not complete successfully
##[error]16:25:26.962 Post-processing failed. Exit code: 1
16:25:26.962 Post-processing failed. Exit code: 1
##[error]The process ‘D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.12.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1

This is our yaml for the build (the scannerMode: ‘MSBuild’ seems wrong, but I can’t think what other value to use)


  • task: SonarCloudPrepare@1
    SonarCloud: ‘{redacted}’
    organization: ‘{redacted}’
    scannerMode: ‘MSBuild’
    projectKey: ‘{redacted}’
    projectName: ‘{redacted}’

  • task: DotNetCoreInstaller@2
    displayName: ‘Install .Net Core 3.x SDK’
    packageType: ‘sdk’
    version: ‘3.x’

  • task: DotNetCoreCLI@2
    displayName: ‘Restore Nugets - dotnet CLI’
    command: ‘restore’
    projects: ‘$(solution)’
    feedsToUse: ‘config’
    nugetConfigPath: ‘NuGet.config’
    externalFeedCredentials: ‘{redacted}t’

  • task: DotNetCoreCLI@2
    displayName: ‘Build Solution - dotnet CLI’
    command: ‘build’
    projects: ‘(solution)' configuration: '(buildConfiguration)’
    arguments: ‘–no-restore’

  • task: DotNetCoreCLI@2
    displayName: ‘Test Solution’
    command: ‘test’
    projects: ‘**/*.Tests.csproj’
    arguments: ‘–collect “Code coverage” --no-restore --no-build’

  • task: SonarCloudAnalyze@1
    displayName: ‘Analysis SonarCloud’

  • task: SonarCloudPublish@1
    displayName: ‘Publish SonarCloud’
    pollingTimeoutSec: ‘300’

Hi @Jason_Dryhurst-Smith and welcome to the community !

Just to be extra sure, did you set your Service Connection to SonarCloud with a token coming from the Security menu of your account on SonarCloud ?


I did. The redacted part is the name of the Service Connection, which is verified. If I change this to a different Service Connection, or a Service Connection to a revoked SonarCloud access token, it fails for a different reason.

Thank you. Could you then send me the log of the SonarCloudAnalyze task in debug mode please ? That would help troubleshoot.

how do I set it to debug mode?

You can add the build variable system.debug and set it to true.

Cool, I thought you meant a debug mode for just the sonarcloud task rather than globally. Will send you the log directly if I can please, there is a lot of sensitive info in there and it doesn’t fit in the reply box anyway, it’s very long.

The build seems to work fine when not part of a PR build.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.