Sonar scan for multiple C# solutions with NANT

I have multipe c# solutions and we use NANT scripts to build the solutions. CI with jenkins job invokes the NANT scripts.

PFA NANT build file : all.build.txt
In jenkins job we simply invoke the attached build file target “FullBuild”. This target has depends on “sonarqube-begin, build, sonarqube-end” targets.

This setup works fine and generates report as well if I just build one sln. The same doesn’t work with multiple sln’s. The attached NANT has multiple references in the target “build”

Any help is appreciated and thanks in advance.

Below is the log:

sonarqube-end:

17:13:06 GMT+05:30
17:13:06 GMT+05:30 [exec] Starting ‘C:/Jenkins/tools/hudson.plugins.sonar.MsBuildSQRunnerInstallation/SonarQubeForMSBuild/SonarScanner.MSBuild.exe (end)’ in ‘C:\Jenkins\workspace\Test_develop’
17:13:06 GMT+05:30 [exec] SonarScanner for MSBuild 4.1
17:13:06 GMT+05:30 [exec] Using the .NET Framework version of the Scanner for MSBuild
17:13:06 GMT+05:30 [exec] Default properties file was found at C:\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarQubeForMSBuild\SonarQube.Analysis.xml
17:13:06 GMT+05:30 [exec] Loading analysis properties from C:\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarQubeForMSBuild\SonarQube.Analysis.xml
17:13:06 GMT+05:30 [exec] Post-processing started.
17:13:06 GMT+05:30 [exec] The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
17:13:06 GMT+05:30 [exec] Possible causes:
17:13:06 GMT+05:30 [exec] 1. The project has not been built - the project must be built in between the begin and end steps
17:13:06 GMT+05:30 [exec] 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
17:13:06 GMT+05:30 [exec] 3. The begin, build and end steps have not all been launched from the same folder
17:13:06 GMT+05:30 [exec] 4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
17:13:06 GMT+05:30 [exec] Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
17:13:06 GMT+05:30 [exec] 07:43:06.639 Creating a summary markdown file…
17:13:06 GMT+05:30 [exec] 07:43:06.641 Post-processing failed. Exit code: 1
17:13:06 GMT+05:30
17:13:06 GMT+05:30 BUILD FAILED - 0 non-fatal error(s), 7 warning(s)

Hi @hari - welcome to the community!

Apologies for the delay in responding; I know nothing about Nant and not much about Jenkins so I hoped someone who did would step in.

First of all, you are using quite an old version of the scanner (and one that does not support the new SDK-style MSBuild projects for example). Before trying anything else, upgrade to the latest version of the scanner, which is currently v4.6.2.

Thanks for the reply Duncan.

I have sorted it out by not using our NANT scripts, instead with MSBUILD commands for each of the solution in the Sonar begin and end statements.

Apologies for not letting you know about the status.

No problem. Thanks for the update.