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
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?
Im using:
…
SonarScanner for MSBuild 6.0
Using the .NET Framework version of the Scanner for MSBuild
…
That is:
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
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 sonarscannerbegin command to get more detailed logs
For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
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.
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?