Hello,
I use the sonarScanner for MsBuild With Build Pipeline in Azure Devops.
Log :
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarQube server.
Version : 4.11.0
Author : sonarsource
SonarQube version is 8.4.2.36762.
My Project is Build by the lastest Version of MsBuild, with Visual Studio 2019.
My project use a framework : .netStandard 2.1
The result sonarqube is empty, and in the log i have this warning :
17:04:08.247 INFO: Sensor C# Properties [csharp]
17:04:08.263 WARN: Analyzer working directory does not exist: ‘D:\agent_work\52.sonarqube\out\1\output-cs’. Analyzer results won’t be loaded from this directory.
Good Morning, @nmathieu! Could you please help me clarifying some points? What do you mean that the result is empty? Could you please navigate to project in sonarqube and check “Code” tab there? Could you see your C# files in there along with their lines of code or is this tab completely empty?
I noticed some inconsistency between the auto-generated folder when building. For instance, on your last build log, it says “D:\agent_work\64\s” and on the run code analysis logs, analysis is made on “D:\agent_work\60\s”. Is that on purpose ? Can you check that on your full pipeline execution, everything goes in the same folder ?
Thanks for the logs. It looks like the Sonar Scanner for MSBuild targets are being executed during the build, but for some reason the SonarC# analyzer is not being executed. The SonarC# analyzer is responsible for calculating the lines of code per file as well as raising analysis issues, which is why no lines of code are being reported in SonarQube.
To help work out what is happening, could you try the following please?
temporarily remove your .editorconfig file and run the CI build to see if that makes a difference.
with the .editorconfig present, run a CI build with diagnostic logging enabled and send us the build logs (i.e. pass /v:diag as argument to MSBuild). That should give us a better idea of why csc.exe is not executing the SonarC# analyzer. If you could share your .editorconfig file that would also be useful.
I upgrade sonarqube to version 8.5.
without the .editorconfig the warning is different:
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 Scanner for MSBuild 4.x, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html.
After deleting I cannot find the .editorconfig file, who generates it?
The final message was changed in SQ 8.5. Since you use Scanner for MsBuild, this message is a side effect of the C# analyzer not being triggered during the csc build.
Do you have any *.targets files in your solution?
.editorconfig is usually added manually. VS can generate it when you do some configuration changes. You should check your backup to see the original file.