Greetings, I searched a lot before opening this topic and unfortunately I didn’t find a solution.
I recently installed Sonarqube Community on an AWS instance
I downloaded the SonarScanner through this link, tested the .Net 5.0 packages and also the .Net 4.6, made the reference in environment variables and then ran the solution in Visual Studio, and then did the scan as directed by Sonarqube.
I used the following commands:
1º "SonarScanner.MSBuild.exe begin /k: "aed2" /d:sonar.host.url="http://ip-server-sonarqube" /d:sonar.login="token""
2º MsBuild.exe /t:Rebuild
3º SonarScanner.MSBuild.exe end /d:sonar.login="token"
It is understood that the words token and ip-server-sonarqube have been replaced because they are sensitive information.
This is the error I get when I finish the scanning steps:
INFO: ------------- Run sensors on project
INFO: C# sensor [csharp]
WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html
INFO: C# sensor [csharp] (done) | time=0ms
INFO: VB.NET sensor [vbnet] (done)
WARN: Your project contains VB.NET files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html
INFO: VB.NET sensor [vbnet] (done) | time=0ms
I also tested with jenkins and get the same error with both, can you help me?
That’s the error you get when you’re not using the SonarScanner for .NET, which your command list indicates you are using. The only thing that catches my eye in your command is the space between /k: and the key string. But I wouldn’t expect it to have that result.
Could you provide the full analysis log, starting from the analysis command?
Ann, I would also like to point out that I tried to run the scanner with jenkins, but also without success, I noticed only one variation: when I run it through jenkins it evaluates the whole project, both front end and back end.
When I run it locally in visual studio, it only scans the backend folders.
When I try to run it locally in another directory, it asks to run it in the solution’s directory.
I look forward to your help, thank you!
Ok, thank you very much, is there anything I can do?
Or some other way to scan the code?
I would like to inform you that my project is made in NetFramework 4.6
Yes, and I have a similar situation when using both locally and on the server, the Scanner sees files but does not scan and refers to the fact that a scanner higher than version 5 is needed. But at the same time there is a 4.6 or 4.7 version of the scanner, Why does this happen?
But to scan the backend I need to use another sequence of commands
SonarScanner.MSBuild.exe begin /k: "name-project" /d:sonar.login="token" /d:sonar.host.url="ip-server-sonarqube"
MSBuild.exe /t:Rebuild /p:RunAnalyzersDuringBuild=true
SonarScanner.MSBuild.exe end /d:sonar.login="token"
But when I’m running on the backend, I run into that error mentioned a few messages above:
tab INFO: ------------- Run sensors on project
INFO: C# sensor [csharp]
WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see SonarScanner for .NET
INFO: C# sensor [csharp] (done) | time=0ms
INFO: VB.NET sensor [vbnet] (done)
WARN: Your project contains VB.NET files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see SonarScanner for .NET
INFO: VB.NET sensor [vbnet] (done) | time=0ms
So, I can’t get the scanning result for all files, I am still facing problems with some C# and VB.NET files.
Can you help me?
Obs:My project is in NetFramework 4.6
In your case it seems that either project detection or the file detection failed. Can you confirm that there are .Net projects in the solution and all these projects have code files (*.cs, *.vb)?
You should also try to provide the path to the *.sln file when running the MsBuild.exe /t:Rebuild command.
If this does not solve the problem, could you please run the analysis in verbose mode and send us the build and the analysis (end step) logs?
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"