SonarCloud Integration with Azure DevOps Pipeline

I am trying to integrate mvc project with Azure Devops Pipeline and also to integrate Sonarcloud for the code Quality.

But, the analysis is failing with an error:

SonarScanner for MSBuild 5.13
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
##[error]19:51:38.843 The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.
Possible causes:

  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    19:51:38.843 The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.
    Possible causes:
  5. The project has not been built - the project must be built in between the begin and end steps
  6. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  7. The begin, build and end steps have not all been launched from the same folder
  8. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    19:51:38.843 Generation of the sonar-properties file failed. Unable to complete the analysis.
    ##[error]19:51:38.874 Post-processing failed. Exit code: 1
    19:51:38.874 Post-processing failed. Exit code: 1
    ##[error]The process ‘E:\dev_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.35.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1
    Finishing: SonarCloudAnalyze

Pipeline YML File:

ASP.NET Core

Build and test ASP.NET Core projects targeting .NET Core.

Add steps that run tests, create a NuGet package, deploy, and more:

Build, test, and deploy .NET Core apps - Azure Pipelines | Microsoft Learn

trigger:

  • master

pool: Default

variables:
buildConfiguration: ‘Release’

steps:

  • script: dotnet build --configuration $(buildConfiguration)
    displayName: ‘dotnet build $(buildConfiguration)’

  • task: SonarCloudPrepare@1
    inputs:
    SonarCloud: ‘SonarCloud’
    organization: ‘poconsonarcloud’
    scannerMode: ‘MSBuild’
    projectKey: ‘POConSonarCloud_SonarCloudProject’
    projectName: ‘SonarCloudProject’

  • task: SonarCloudAnalyze@1

  • task: SonarCloudPublish@1
    inputs:
    pollingTimeoutSec: ‘300’

https://dev.azure.com/POConSonarCloud/_git/SonarCloudProject - Project details

Hi @Umar - welcome to the community.

Since you are using the Azure DevOps extension, that means the project must be built between the SonarCloudPrepare and SonarCloudAnalyze steps.

Thank You. I am trying to make the changes.