C# Code is not detected and analyzed in .net Core projects using CLI and SonarCloud

Version: Sonar Cloud
Integration: Azure DevOps Services
Scanner Mode: CLI

We are working with several git repositories. Some contain old .net Code that need to be compiled with MSTest. So we are using scanner mode “MSTest”. Everything works as expected.

If like to build a .net Core Code or .net 5 Code, we need to build it with CLI instead of MSBuild. So we use the Scanner Mode “CLI”. In result, only HTML and CSS files are detected but not the C# Code.

We do not exclude anything by purpose. What is the issue?

task: SonarCloudPrepare@1

    inputs:

        SonarCloud: 'Sonar Cloud'

        organization: 'beckerbillett'

        scannerMode: 'CLI'

        configMode: 'manual'

        cliProjectKey: 'Beckerbillett_GlobalApi'

        cliProjectName: 'GlobalApi'

        cliSources: '.'

        extraProperties: |

            sonar.exclusions= **/wwwroot/**/*.*, **/*.Test/**/*.*

            sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml

            sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx

            sonar.verbose=true

Hi @Nils - welcome to the community.

Use ‘MSBuild’ (not ‘MSTest’) mode.

Under the covers, all C# projects are built using MSBuild, regardless of whether they are targeting .NET Core or .NET Fx.