Latest SonarScanner failed on .net 4.8 project

Hi.

SonarQube on docker.

  • Community Edition
  • Version 10.3 (build 82913)
  • Sonar-scanner-5.0.1.3006
  • openjdk version “17.0.9” 2023-10-17 LTS

I try to run locally SonarScanner on c# project, Visual Studio 2022, .net 4.8. On ending command SonarScanner.MSBuild.exe end…

i got exception:

INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.ExceptionInInitializerError
        at org.sonarsource.scanner.cli.SystemInfo.print(SystemInfo.java:42)
        at org.sonarsource.scanner.cli.Main.init(Main.java:109)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
        at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.NullPointerException: source
        at java.base/java.util.Objects.requireNonNull(Objects.java:235)
        at java.base/java.util.Scanner.<init>(Scanner.java:595)
        at java.base/java.util.Scanner.<init>(Scanner.java:581)
        at org.sonarsource.scanner.cli.ScannerVersion.<init>(ScannerVersion.java:31)
        at org.sonarsource.scanner.cli.ScannerVersion.<clinit>(ScannerVersion.java:26)
        ... 4 more
ERROR:
The SonarScanner did not complete successfully
18:15:00.706  Post-processing failed. Exit code: 1

Any idea how to resolve this issue?
Regards.

Hey there.

Just to be quite sure (since you mention v5.0.1 when filling out the template), are you using the latest version of the Scanner for .NET, which is v6.0?

Hi.

Im using:

SonarScanner for MSBuild 6.0
Using the .NET Framework version of the Scanner for MSBuild

That is:
obraz
from sonar-scanner-6.0.0.81631-net-framework.zip.

I mistakenly entered the name of a subdirectory from this archive: sonar-scanner-5.0.1.3006

Hi @Tejot

We’ll need the logs:

  • please give us the verbose output of the scanner commands (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of the BEGIN and END steps)
  • please give the output of running MSBuild in verbose mode (/v:d)

Also, please tell us:

  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
  • The important logs are in the END step

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

Hi :slight_smile: .

Logs attached. Start, build and end. I send the content of build compressed.

Commands:

SonarScanner.MSBuild.exe begin /k:"ZZZ-Analizy-Olap" /d:sonar.host.url="https://xxx" /d:sonar.token="xxx" /d:"sonar.verbose=true"

"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MsBuild.exe" /t:Rebuild /v:d

SonarScanner.MSBuild.exe end /d:sonar.token="xxx"

Running from the solution folder.
build.zip (71.8 KB)
end.log (16.8 KB)
start.log (6.6 KB)
folder.

Hi @Tejot.

Sorry for the delayed response. We are still investigating this but have been unable to reproduce it.

Did you try to scan this project on another computer/setup?
Did you try to scan another project in the same setup?

Hi @Tejot

Sorry again for the long delay in the investigation.

The error seems to indicate that a file is missing in the scanner distribution. This is strange because the missing file should be included in one of the scanner libraries. Maybe the distribution got corrupted in your environment?
If you are still affected, may I ask you to check the content of the file C:\!\tools\sonar-scanner\sonar-scanner-5.0.1.3006\lib\sonar-scanner-cli-5.0.1.30006.jar (you can open it as a ZIP archive). The file version.txt should be present at the root.

Then I would suggest getting a fresh installation of the SonarScanner for .NET and trying again.

Best,