File **/**/[Filename].cs can't be indexed twice

I am trying to run a POC on SonarQube and a solution to illustrate the need for analysis tooling in the pipeline.

Problem: File Apps/Apps.Api/DataExchangeRateLimitConfiguration.cs can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files.

If I exclude “Apps/Apps.Api” another folder just becomes the problem.

I have been reading various posts, but most are related to duplicate use of source.

Running:

  • SonarQube Community Edition Version 9.2.4 (build 50792)
  • sonar-scanner-4.6.2.2472
  • mixed js and C#
  • running from a bat file on Windows

This is the bat script I am using: (org. names removed)

SET projectName="[Projectname]"
SET projectKey="[Projectname]"
SET sources="C:/Development/[Subname]/source"
SET sln_path="%sources%/[Projectname].sln"
SET msbuild_path="C:/TestTools/Sonar-scanner-msbuild-net5.0/SonarScanner.MSBuild.dll"
SET login="[key]"
SET exclusions="**/**/**/**/Apps/Apps.Api/*.json"
SET host_url="http://localhost:9000"
SET sourceEncoding=UTF-8
SET verbose=true

ECHO ============START RUNNING SCANNER==============
dotnet %msbuild_path% begin /k:%projectName% /d:sonar.host.url=%host_url% /d:sonar.sourceEncoding=%sourceEncoding% /d:sonar.verbose=%verbose% /d:sonar.exclusions=%exclusions% /d:sonar.sources=%sources% /d:sonar.login=%login%

dotnet build %sln_path%
dotnet %msbuild_path% end /d:sonar.login=%login%
ECHO ============DONE RUNNING SCANNER==============
ECHO ============PAUSING==============
PAUSE

Hey there.

You should almost never need to specify sonar.sources when using the Scanner for .Net. What happens if you leave it out?

Hi Colin. Thank you for your excellent suggestion. It worked! :grinning:
I had this issue twice now. It just goes to show what happens if you ask the question at the right place

1 Like

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