Exclude files does not seem to work

Hi,

I have a problem with excluded files. We have set the exclude sources parameter with **/Migrations/*. See screenshot below:

but issues are still found within files of the Migrations folder see screenshots below of the Sonarcloud Analysis

I didn’t expect these WARN lines in this Sonarcloud Code Analysis logging.

Does anyone know why these lines still appear in our logging?

Hey there.

Due to some particularities of C# analysis, all files get analyzed (during the build of your project) and then files are filtered out based on your exclusions during the SonarQubeAnalyze step.

Because there are issues in the roslyn reports that ultimately don’t exist n your analysis scope (because you’ve excluded the files), you end up with some warnings in your logs. You should be able to safely ignore these.

I’m mindful that maybe these should be at another log level (like DEBUG), so I’ll flag this for attention (there could be a very good reason we show these warnings).

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

Hi @Adrie

Thanks for raising the point, the behavior you mention looks quite annoying.

Would you have a small reproducer project that we could clone and play around with, to better understand the problem? Your help to improve our products is highly appreciated!

At a first glance, I think those files should be detected as generated code by our Roslyn analyzers, and it seems they are not - we should understand why. Can you share the debug build logs and the debug END step logs with us?

And at a second glance, it seems like we don’t look at Exclusions when importing metrics for the code (metadata for code highlighting, for example).

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

Best,
Andrei

Hi Andrei,

Sorry for the late reaction due to holidays. Unfortunately most of my team is currently on holiday so I cannot deliver the verbose logs quickly. I have put this action on the backlog and somewhere in august I will share the logs from the END step.

Best regards,
Adrie

Problem found … it was something stupid! The source file with the excluded block was used in a different pipeline. We were mixed up. The holidays were helpfull to clear our minds.
Problem solved.

1 Like

Sometimes, I come back to a problem in this community a month later and see things I never saw, even after hours of looking at it before. I totally understand!

1 Like

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