0

I am executing Sonar in GitHub using SonarScanner - dotnet tool install --global dotnet-sonarscanner --version 5.2.2 - and it is providing a result.

SonarQube: Community version 7.9.4

dotnet-SonarScanner: 4.10.0 / 5.2.2 (tried with both and earlier was working with 4.10.0)

The following shell script I'm using to execute the sonar as follow:

PowerShell Script

dotnet sonarscanner begin /key:$projectKey `
    /d:sonar.log.level="DEBUG" `
    /v:"$(gitversion /nofetch /showvariable AssemblySemVer)" `
    /d:sonar.links.scm=$repository `
    /d:sonar.scm.provider="git" `
    /d:sonar.scm.revision="$(git rev-parse HEAD)" `
    /d:sonar.buildString="$(gitversion /nofetch /showvariable NuGetVersion)" `
    /d:sonar.host.url="https://ccq.svc.myorg.com" `
    /d:sonar.login=$token `
    /d:sonar.cs.opencover.reportsPaths="$pwd\CodeCoverageReports\CoverageReport.xml" `
    /d:sonar.cs.xunittest.reportsPaths="$pwd\TestResults\TestResults.xml"
    
& $msbuild $solutionName /p:Configuration=Release /t:Build -maxcpucount:1 /consoleloggerparameters:NoSummary
    
dotnet sonarscanner end "/d:sonar.login=$token"

But when a result is updated in SonarQube it is not analyzing the C# files and analyzing the XML & JS files only.

I have crossed-checked in SonarQube > Project > Aministration > General Settings and there is no files excluded.

Can you pls share what am I missing here?

I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
  • Since you are using target build instead of rebuild, are you sure that the software is actually built? If the software was already built, target build will do nothing and SonarQube will not detect any files. – raspy Jul 01 '21 at 12:13
  • @raspy: I tried with rebuild and still no luck. – I Love Stackoverflow Jul 01 '21 at 12:52
  • If you are using `dotnet sonarscanner` you are supposed to build your project using `dotnet build`, not `msbuild`. For MSBuild you would need to use `SonarScanner.MSBuild.exe begin`. Consult the [documentation](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/#header-3). – raspy Jul 01 '21 at 14:18
  • Is it because of some version change? Because with same settings it was working fine earlier approx. 1 month back. And sorry I forgot to mention this part in details - I have tried it with `SonarScanner.MSBuild.exe` but it didn't work with it either. – I Love Stackoverflow Jul 01 '21 at 16:23

0 Answers0