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,

Hi.

Thank you for your tips.
I got newest Releases · SonarSource/sonar-scanner-msbuild · GitHub, did not help

C:\!\tools\sonar-scanner\sonar-scanner-5.0.1.3006\lib\sonar-scanner-cli-5.0.1.30006.jar:

I will try to run it on another computer.

Best.

Hi.

I will add that I have a second project based on the .netcore environment. Works flawlessly.

This is even more puzzling :slight_smile:

OK, so let me try to summarize, and correct me if I am wrong:

  • you are trying to analyze a dotnet framework project, running the SonarScanner for .NET (6.2.0-net-framework bundle) from your development machine
  • the analysis fails in the end step, with NullPointerException: source at org.sonarsource.scanner.cli.ScannerVersion.<init>(ScannerVersion.java:31)
  • doing exactly the same on a dotnet core project (so using the 6.2.0-net bundle) on the same machine works fine

If the previous statements are correct, I don’t really understand the source of the problem. The only guess would be that some anti-malware program (like Windows Defender) would be interfering, and that its behavior would be different if the entry point is dotnet framework or dotnet core, but this would be the first time I see this case. If you have permission on your machine, can you temporarily put the scanner installation folder in the whitelist of your anti-malware, and see if that fixes the issue?

Hi.

These are two completely different projects. One based on .net and the other on .netcore.

I will try to “disable” Defender/ESET and repeat the tests. I’ll write what happened

Best regards.