Error in 'Run Code Analysis' task in Azure Devops

Hi Everyone ,
I run sonarqube analysis from Ci build definition in Azure Devops .
I am getting an error on task ‘Run Code Analysis’ , attached the log below .
Can you please guide what the issue here is ?

There are other projects for which sonarqube analysis is working fine , they are in same azure devops organisation having agent on same agent server . I am getting this issue for just one project .
Also ,I noticed on agent server that sonarqube files are not getting generated properly .
I’m not sure what’s the root cause here .

Logs on task ‘Run Code analysis’

2020-09-17T08:12:21.4747813Z ##[debug]Evaluating condition for step: 'Run Code Analysis'
2020-09-17T08:12:21.4749994Z ##[debug]Evaluating: succeeded()
2020-09-17T08:12:21.4750494Z ##[debug]Evaluating succeeded:
2020-09-17T08:12:21.4751583Z ##[debug]=> True
2020-09-17T08:12:21.4752091Z ##[debug]Result: True
2020-09-17T08:12:21.4752649Z ##[section]Starting: Run Code Analysis
2020-09-17T08:12:21.4895990Z ==============================================================================
2020-09-17T08:12:21.4896369Z Task         : Run Code Analysis
2020-09-17T08:12:21.4896657Z Description  : Run scanner and upload the results to the SonarQube server.
2020-09-17T08:12:21.4896908Z Version      : 4.11.0
2020-09-17T08:12:21.4897097Z Author       : sonarsource
2020-09-17T08:12:21.4897571Z Help         : Version: 4.11.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2020-09-17T08:12:21.4898163Z ==============================================================================
2020-09-17T08:12:21.9996948Z ##[debug]agent.TempDirectory=D:\VSTS Agent Folder\DIV\_temp
2020-09-17T08:12:22.0053155Z ##[debug]loading inputs and endpoints
2020-09-17T08:12:22.0058033Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2020-09-17T08:12:22.0072936Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2020-09-17T08:12:22.0079657Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2020-09-17T08:12:22.0089834Z ##[debug]loading SECRET_SONARQUBE_ENDPOINT
2020-09-17T08:12:22.0099255Z ##[debug]loaded 4
2020-09-17T08:12:22.0122848Z ##[debug]Agent.ProxyUrl=undefined
2020-09-17T08:12:22.0124703Z ##[debug]Agent.CAInfo=undefined
2020-09-17T08:12:22.0125002Z ##[debug]Agent.ClientCert=undefined
2020-09-17T08:12:22.0125344Z ##[debug]Agent.SkipCertValidation=undefined
2020-09-17T08:12:22.0871514Z ##[debug]SONARQUBE_SCANNER_MODE=MSBuild
2020-09-17T08:12:22.0872466Z ##[debug]JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_172
2020-09-17T08:12:22.0872815Z ##[debug]JAVA_HOME_11_X64=undefined
2020-09-17T08:12:22.0881212Z ##[debug]SONARQUBE_SCANNER_MSBUILD_EXE=D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2020-09-17T08:12:22.0884839Z ##[debug]which 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.0892811Z ##[debug]found: 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.0893475Z ##[debug]which 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.0894109Z ##[debug]found: 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.0897253Z ##[debug]D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: end
2020-09-17T08:12:22.0903739Z ##[debug]exec tool: D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2020-09-17T08:12:22.0904228Z ##[debug]arguments:
2020-09-17T08:12:22.0904479Z ##[debug]   end
2020-09-17T08:12:22.0919010Z [command]"D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe" end
2020-09-17T08:12:22.2003598Z SonarScanner for MSBuild 4.10
2020-09-17T08:12:22.2003996Z Using the .NET Framework version of the Scanner for MSBuild
2020-09-17T08:12:22.2538700Z Post-processing started.
2020-09-17T08:12:22.3718572Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3721269Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3721947Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3722615Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3723248Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3723893Z 08:12:22.364  08:12:22.301  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3724523Z 08:12:22.364  08:12:22.317  Uninstalling target: C:\Users\SVC-DEVOPSCI\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
2020-09-17T08:12:22.3725043Z 08:12:22.364  08:12:22.364  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2020-09-17T08:12:22.3726431Z 08:12:22.364  Loading the SonarQube analysis config from D:\VSTS Agent Folder\DIV\52\.sonarqube\conf\SonarQubeAnalysisConfig.xml
2020-09-17T08:12:22.3727485Z 08:12:22.364  TeamBuild environment detected
2020-09-17T08:12:22.3729613Z 08:12:22.364  Analysis base directory: D:\VSTS Agent Folder\DIV\52\.sonarqube
2020-09-17T08:12:22.3730102Z Build directory: D:\VSTS Agent Folder\DIV\52
2020-09-17T08:12:22.3730451Z Bin directory: D:\VSTS Agent Folder\DIV\52\.sonarqube\bin
2020-09-17T08:12:22.3730815Z Config directory: D:\VSTS Agent Folder\DIV\52\.sonarqube\conf
2020-09-17T08:12:22.3731210Z Output directory: D:\VSTS Agent Folder\DIV\52\.sonarqube\out
2020-09-17T08:12:22.3731585Z Config file: D:\VSTS Agent Folder\DIV\52\.sonarqube\conf\SonarQubeAnalysisConfig.xml
2020-09-17T08:12:22.3768328Z 08:12:22.364  Attempting to locate the CodeCoverage.exe tool...
2020-09-17T08:12:22.3809050Z 08:12:22.379  Attempting to locate the CodeCoverage.exe tool using setup configuration...
2020-09-17T08:12:22.4002708Z 08:12:22.395  Attempting to locate the CodeCoverage.exe tool using registry...
2020-09-17T08:12:22.4030116Z 08:12:22.395  08:12:22.395  WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
2020-09-17T08:12:22.4094825Z Generating SonarQube project properties file to D:\VSTS Agent Folder\DIV\52\.sonarqube\out\sonar-project.properties
2020-09-17T08:12:22.4146592Z ##[error]The SonarQube MSBuild integration failed: SonarQube 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)
2020-09-17T08:12:22.4149721Z ##[debug]Processed: ##vso[task.logissue type=error;]The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.%0D%0APossible causes:%0D%0A  1. The project has not been built - the project must be built in between the begin and end steps%0D%0A  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.%0D%0A  3. The begin, build and end steps have not all been launched from the same folder%0D%0A  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2020-09-17T08:12:22.4151576Z The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2020-09-17T08:12:22.4151875Z Possible causes:
2020-09-17T08:12:22.4152152Z   1. The project has not been built - the project must be built in between the begin and end steps
2020-09-17T08:12:22.4152558Z   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
2020-09-17T08:12:22.4152952Z   3. The begin, build and end steps have not all been launched from the same folder
2020-09-17T08:12:22.4153290Z   4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2020-09-17T08:12:22.4193545Z Writing processing summary to D:\VSTS Agent Folder\DIV\52\.sonarqube\out\ProjectInfo.log
2020-09-17T08:12:22.4234691Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2020-09-17T08:12:22.4279106Z ##[error]08:12:22.426  Post-processing failed. Exit code: 1
2020-09-17T08:12:22.4280798Z ##[debug]Processed: ##vso[task.logissue type=error;]08:12:22.426  Post-processing failed. Exit code: 1
2020-09-17T08:12:22.4281200Z 08:12:22.426  Post-processing failed. Exit code: 1
2020-09-17T08:12:22.4401642Z ##[debug]Exit code 1 received from tool 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.4402849Z ##[debug]STDIO streams have closed for tool 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2020-09-17T08:12:22.4524175Z ##[debug]task result: Failed
2020-09-17T08:12:22.4525344Z ##[error]The process 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2020-09-17T08:12:22.4527392Z ##[debug]Processed: ##vso[task.issue type=error;]The process 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2020-09-17T08:12:22.4538042Z ##[debug]Processed: ##vso[task.complete result=Failed;]The process 'D:\VSTS Agent Folder\DIV\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.11.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2020-09-17T08:12:22.4663768Z ##[section]Finishing: Run Code Analysis

Hi @Rehan!
Can you please confirm that your CI pipeline

  1. Builds a .NET project
  2. Contains all mandatory tasks in the right order, which means SonarQube Prepare Analysis task |–> Build |–> SonarQube Run Analysis task

Kind regards,
Christophe

Hi Christophe,
The issue is fixed when I place the task ‘SonarQube Prepare Analysis’ befoe the ‘Build solution’ task .
Regards,
Rehan

I glad to hear that :slight_smile:

Kind regards,
Christophe

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