Unable to include and exclude files for sonar

Hi,

I use SonarQube Scanner CLI version 3.0 for SonarCude MS Build, file inclusion and exclusions are not working as i configured in the sonar-scanner.properties settings File

By default it’s pusing XML, HTML, CSS content to the sonar qube site.

Kindly help me on this.

Thanks,
Rex Andrew I

Hi @Rex_Andrew - welcome to the community.

I’m not clear what you mean by “SonarQube Scanner CLI version 3.0 for SonarQube MS Build”.
The Sonar Scanner CLI and the SonarScanner for .NET (formerly MSBuild) are different things.

The SonarScanner for .NET does not use a properties files. You can pass parameters to the SonarScanner for .NET in a SonarQube.Analysis.xml files as described in the docs linked to above, or you could set the inclusions/exclusions in the SonarQube UI.

If you are using inclusion/exclusions to disable the analysis of specific languages, have a look at this thread which suggests a couple of alternative approaches.

Hi Duncan Pocklington,

Thanks for your response. I am using the SonarQube.Analysis.xml file, but it’s not considering the inclusion and exclusion mentioned in it.

@Rex_Andrew it looks like you are using v2 of the SonarQube VSTS extension from 2016. Is that correct?

That version of the extension has been obsolete for some time. I’m guessing that you are using an old self-hosted version of Azure/VSTS and can’t upgrade to the v4 version of the SonarQube extension (although if you can, you should).

I’m struggling to any documentation for that version of the task. Looking at the original release announcement, if you want to scan C# code then you only need the SonarQube Scanner for MSBuild - Begin Analysis and SonarQube Scanner for MSBuild - End Analysis tasks. You should be passing the settings to the scanner in the “Begin” step.

Alternatively, set the inclusions/exclusions in the UI.

The SonarQube Scanner CLI task is for non-MSBuild projects. That is probably what is push the XML etc results to the server.

Hi @duncanp ,
Thank you so much for your response, I will try with SonarQube Scanner for MSBuild - Begin Analysis and SonarQube Scanner for MSBuild - End Analysis tasks