I’m evaluating whether SonarCloud can be a fit for some of my projects. Both open source and otherwise.
I’ve noticed others having similar issues to mine, for example: When will there be support for .Net Core 3 in SonarScanner for Azure DevOps? - #9 by martinmani
In my Azure DevOps pipeline I’ve followed the steps of the configuration guides, but had to modify it according to the link above for it to even work. If I don’t modify it according to the final comment in the previous link, the build step complains that .NET 2.0.0 doesn’t exist - everything in my project is on .NET 3.x.
When I modify it as per the above link, there’s no results.
First, the SonarCloud web tells me that “main” branch hasn’t been analyzed, which is OK - when I switch to the “develop” branch, it says there’s no issues found. However, with the linter there are issues found - so the analysis from SonarCloud doesn’t produce the desired results.
When I review the logs, I can see that it has picked up C# code for analysis:
INFO: Sensor C# [csharp] INFO: Importing results from 5 proto files in 'D:\a\1\.sonarqube\out\0\output-cs' INFO: Importing results from 5 proto files in 'D:\a\1\.sonarqube\out\3\output-cs' INFO: Importing results from 5 proto files in 'D:\a\1\.sonarqube\out\2\output-cs' INFO: Importing results from 5 proto files in 'D:\a\1\.sonarqube\out\4\output-cs' INFO: Importing results from 5 proto files in 'D:\a\1\.sonarqube\out\1\output-cs' INFO: Importing 5 Roslyn reports INFO: Sensor C# [csharp] (done) | time=728ms INFO: Sensor Zero Coverage Sensor INFO: Sensor Zero Coverage Sensor (done) | time=45ms INFO: SCM Publisher SCM provider for this project is: git INFO: SCM Publisher 99 source files to be analyzed INFO: SCM Publisher 99/99 source files have been analyzed (done) | time=1987ms INFO: CPD Executor 15 files had no CPD blocks INFO: CPD Executor Calculating CPD for 77 files INFO: CPD Executor CPD calculation finished (done) | time=71ms INFO: SCM writing changed lines WARN: Could not find ref: main in refs/heads, refs/remotes/upstream or refs/remotes/origin INFO: SCM writing changed lines (done) | time=7ms INFO: Analysis report generated in 1587ms, dir size=755 KB INFO: Analysis report compressed in 269ms, zip size=347 KB INFO: Analysis report uploaded in 207ms INFO: ANALYSIS SUCCESSFUL, you can find the results at: <redacted>
- What’s required for the SonarCloud build steps to -actually- work with .NET 3.x without the workaround for .NET 2.0.0 build steps?
- Do we have to configure something specifically when the .sln or .csproj files are NOT in the project root, but rather in ~repo/src/folder/thesolution.sln (other than wildcards, or full paths in the build steps).
- Can I tell SonarCloud that “develop” is my main branch?
I am evaluating SonarCloud both for developers, and for enterprises where we need to generate reporting.