Run Code Analysis step failed

Hi,

I am trying to setup Sonarqube with Azure DevOps pipeline. But getting the below error. Any idea, what causing this issue.

Prepare Code Analysis Logs:

2022-07-26T09:12:50.7770282Z ##[section]Starting: Run Code Analysis
2022-07-26T09:12:50.8210040Z ==============================================================================
2022-07-26T09:12:50.8210587Z Task         : Run Code Analysis
2022-07-26T09:12:50.8210993Z Description  : Run scanner and upload the results to the SonarQube server.
2022-07-26T09:12:50.8211347Z Version      : 5.6.1
2022-07-26T09:12:50.8211608Z Author       : sonarsource
2022-07-26T09:12:50.8212365Z Help         : Version: 5.6.1. 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)
2022-07-26T09:12:50.8213251Z ==============================================================================

Run Code Analysis Logs:

2022-07-26T09:12:51.2674997Z [command]C:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.6.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2022-07-26T09:12:51.4267384Z SonarScanner for MSBuild 5.6
2022-07-26T09:12:51.4269132Z Using the .NET Framework version of the Scanner for MSBuild
2022-07-26T09:12:51.4948082Z Post-processing started.
2022-07-26T09:12:51.6448727Z ##[error]09:12:51.629  The SonarScanner for 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)
2022-07-26T09:12:51.6464453Z 09:12:51.629  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2022-07-26T09:12:51.6467596Z Possible causes:
2022-07-26T09:12:51.6468862Z   1. The project has not been built - the project must be built in between the begin and end steps
2022-07-26T09:12:51.6472203Z   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
2022-07-26T09:12:51.6473519Z   3. The begin, build and end steps have not all been launched from the same folder
2022-07-26T09:12:51.6474707Z   4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2022-07-26T09:12:51.6475763Z 09:12:51.629  Generation of the sonar-properties file failed. Unable to complete the analysis.
2022-07-26T09:12:51.6502730Z ##[error]09:12:51.644  Post-processing failed. Exit code: 1
2022-07-26T09:12:51.6506769Z 09:12:51.644  Post-processing failed. Exit code: 1
2022-07-26T09:12:51.6726346Z ##[error]The process 'C:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.6.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2022-07-26T09:12:51.6845851Z ##[section]Finishing: Run Code Analysis

Hi,

Welcome to the community!

Did you Rebuild in between? That’s when that information collection happens…

 
Ann

Hi Ann,

Thank you!!

No, I have not rebuilt… This is the very first time I am doing this through Azure build Pipeline.

-Sandeep

Hi Sandeep,

.NET analysis won’t work unless you (re)build your code. You need to do a full build for each analysis, so it’s best to use the Rebuild command, even if you haven’t built previously. The docs should help.

 
Ann

Hi Ann,

Thanks for your help. I am trying to do the same, but not sure MSBuild.exe is not working. VS build tools is installed. I am trying to build a solution which is there in Azure Repo and I am passing the URL. Could you please help me here how to rebuild this?

Thanks,
Sandeep

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin>MSBuild.exe Azure DevOps Services | Sign In /t:Rebuild
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1009: Project file does not exist.
Switch: Azure DevOps Services | Sign In

Hi Sandeep,

That’s a bit out of scope and certainly beyond my expertise.

 
Sorry,
Ann

Hi Ann,

It is Ok. No Problem.

But if it is possible for you to pass this to someone who can help here.

Thanks,
Sandeep