Analyzing .NET Core 3.x projects doesn't yield any results

Hey,

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>
  1. 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?
  2. 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).
  3. 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.

Welcome to the community!

I’m afraid what you found in the linked thread is still true today: our extension still does not support .NET Core 3.x. We did spend some time on, discovered that it’s a bit more complex to do than we had thought, and then haven’t made further progress. Our .NET expert is on holiday at the moment, I will notify him of this thread and he can provide more up to date information.

In the meantime, there are a few things we can try. To make develop the main branch, please follow the workaround explained in this other thread. Once that’s done, I’m curious if after running an analysis, and you go to the Code tab, do you see correctly the source code files where you expect issues to be reported. Please let me know!

Hi @zimmergren ,

You just can’t use the SonarCloud extension for Azure DevOps (there’s a .NET core 3 flavor). You will need to run the Scanner for .NET on its standalone version, with the proper analysis settings.

Does that mean that your sources are also in ~repo/src/folder/something ? If yes, you’ll need to execute both the scanner and the build, preferably, from this directory.

Janos already gave you a link to do so. Did that work ?

HTH,
Mickaël

Hey @mickaelcaro ,
Thanks for the reply!

I wasn’t aware of the Scanner for .NET. I suppose you’re referring to this: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild - I’ll get that set up and verify.

Yeah, that’s the same, just a new name starting version 5.0 (though we still have many reference to MSBuild, slowly changing all those occurences)