The exclusion of folders produce an indexed twice error on a file that should be excluded.
Why it is indexed twice as it should be excluded from filtering?
How can I exclude a full folder and some files with that structure?
The project structure
c:\src\SonarExamples\sonarqube-scanner-msbuild
+---CSharpProject
| +---SomeConsoleApplication
| \---SomeConsoleApplicationTest
\---Outputs
\---Prints
\---SomeConsolePrints
The filter we used in our pipeline is:
variables:
projectSourceDir: 'sonarqube-scanner-msbuild'
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'my-organization'
scannerMode: 'MSBuild'
projectKey: 'SonarKey'
projectName: 'SonarExamples'
projectVersion: '${{ parameters.ProjectVersion }}'
extraProperties: |
sonar.sources = $(projectSourceDir)/CSharpProject/
sonar.exclusions = **/AssemblyInfo.cs,$(projectSourceDir)/CSharpProject/SomeConsoleApplicationTest/**/*,$(projectSourceDir)/Outputs/**/*
sonar.cpd.exclusions=**/AssemblyInfo.cs
The result gives an error
Starting: SonarCloudAnalyze
INFO: Project configuration:
INFO: Excluded sources: **/build-wrapper-dump.json, **/AssemblyInfo.cs, sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplicationTest/**/*, sonarqube-scanner-msbuild/Outputs/**/*
INFO: Excluded sources for duplication: **/AssemblyInfo.cs
INFO: Indexing files of module 'SomeConsoleApplicationTest'
INFO: Base dir: D:\a\1\s\sonarqube-scanner-msbuild\CSharpProject\SomeConsoleApplicationTest
INFO: Test paths: ProgramTests.cs, Properties/AssemblyInfo.cs
INFO: Excluded sources: **/build-wrapper-dump.json, **/AssemblyInfo.cs, sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplicationTest/**/*, sonarqube-scanner-msbuild/Outputs/**/*
INFO: Excluded sources for duplication: **/AssemblyInfo.cs
INFO: Indexing files of module 'SomeConsoleApplication'
INFO: Base dir: D:\a\1\s\sonarqube-scanner-msbuild\CSharpProject\SomeConsoleApplication
INFO: Source paths: Program.cs, Properties/AssemblyInfo.cs, App.config
INFO: Excluded sources: **/build-wrapper-dump.json, **/AssemblyInfo.cs, sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplicationTest/**/*, sonarqube-scanner-msbuild/Outputs/**/*
INFO: Excluded sources for duplication: **/AssemblyInfo.cs
INFO: Indexing files of module 'SomeConsolePrints'
INFO: Base dir: D:\a\1\s\sonarqube-scanner-msbuild\Outputs\Prints\SomeConsolePrints
INFO: Source paths: Program.cs, Properties/AssemblyInfo.cs, App.config
INFO: Excluded sources: **/build-wrapper-dump.json, **/AssemblyInfo.cs, sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplicationTest/**/*, sonarqube-scanner-msbuild/Outputs/**/*
INFO: Excluded sources for duplication: **/AssemblyInfo.cs
INFO: Indexing files of module 'SonarExamples'
INFO: Base dir: D:\a\1\s
INFO: Source paths: sonarqube-scanner-msbuild/CSharpProject
INFO: Excluded sources: **/build-wrapper-dump.json, **/AssemblyInfo.cs, sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplicationTest/**/*, sonarqube-scanner-msbuild/Outputs/**/*
INFO: Excluded sources for duplication: **/AssemblyInfo.cs
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]ERROR: File sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplication/App.config can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
ERROR:
ERROR: File sonarqube-scanner-msbuild/CSharpProject/SomeConsoleApplication/App.config can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
ERROR: