Issues scanning some .NET projects

Hi,

We have the following versions:

  • SonarQube version: Community Edition Version 8.9.8
  • SonarScanner version: 4.8.0.2856
  • .NET version used by a development project: .NET Core 2.221.0

We have planned an update to the latest version of SonarQube Community deployed in a Docker, but in the meanwhile we are having issues because C# code is not being analyzed by Sonar and it’s not even considered as LoC in the “measures” area.

The following warning is shown in the pipeline logs: “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

I have consulted the other posts related with this issue but I can’t figure out some things for fixing our issue.

I would like to know which version of SonarScanner should we use and if it’s possible to do it with our community edition version. Also, will the issue be solved when we update to the latest version?

Thank you very much, please ask for any additional information if needed.

Hi

Yes, you’ll need to use the Scanner for .NET and the instructions on how to set it up are on the page you link to. If you still have issues with this can you give me some more details on the commands you are using to run the analysis?

Tom

Hi, thank you for your help.

I am using the Scanner for .NET and it’s working well in other projects that are using .NET compatible versions, so this shouldn’t be a problem with the set up. The analysis are running well but with this particular projects they are ignoring the C# code. My questions are:

  • Can I use another version of the SonarScanner with this SonarQube version?
  • If yes, how can I know which version works with this .NET version?
  • And on a different approach, will the issue be solved when we update to the latest version?

Thank you again.

Hi Again

  • Can I use another version of the SonarScanner with this SonarQube version?

Yes, scanner versions are backward compatible with older supported SQ versions unless we specify otherwise.

  • If yes, how can I know which version works with this .NET version?

For .NET 2.2 you can either use the .NET CLI version (which will select the latest correct .NET core version for you) or you can download the version for .NET 2.1 directly from the link at the top of this page. Please note since this version of .NET is no longer supported by Microsoft we may drop support for using it as a runtime in the future (although you will still be able to analyse code targetting unsupporting versions if you need)

  • And on a different approach, will the issue be solved when we update to the latest version?

I can’t say, but 8.9 is no longer supported so you should update to at least the latest LTS version. The analyser is continually being improved so you will get a much improved analysis on the latest SQ version.

Hope that helps

Tom

Thank you very much Tom, I’ll try these approaches.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.