I finally started using SonarQube for code analysis in my projects recently, by setting up a community version of SonarQube server(offline) and was successfully able to integrate it on 2 of my .Net projects over Azure DevOps build pipeline. These .Net projects had unit test cases written with a 100% success rate.
Interestingly, i have come across a strange issue of the "Run Code Analysis" task on my Azure DevOps pipeline failing, when i tried to integrate on projects that do not have Unit test cases written or on projects where a few unit tests fails.
Below is the error that i get on the "Run Code Analysis" task for a project where few Unit tests fail.
"No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details. 17:28:49.847 Post-processing failed. Exit code: 1 The process 'C:\VNA2_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.7.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1"
And on .Net projects without any Unit tests, i get the following error and my pileline fails but i can see some SCA results on SonarQube dashboard but probably not precise and VC++ projects only the error part and no results.
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 and 15.0 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) 17:43:27.653 Post-processing failed. Exit code: 1 The process 'C:\VNA3_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.7.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Anyone out here has faced these same challenges or have an idea of what's happening and how to get around it? Kindly help out. I also tried adding additional properties on the "Prepare Analysis" task pointing to my source directory and also tried checking in sonar.properties file too with the following code.
sonar.dotnet.visualstudio.solution.file=mySln.sln sonar.sourcesDirectory=$(build.sourcesDirectory)\slnDirectory sonar.dotnet.excludeGeneratedCode=true sonar.dotnet.4.0.sdk.directory=C:/Windows/Microsoft.NET/Framework64/v4.0.30319 sonar.dotnet.version=4.6.2 sonar.visualstudio.enable=true
Note: I am using msbuild 16.0 to build my projects.