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

**URL:** <https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774>\
**Category:** SonarQube Server / Community Build\
**Tags:** dotnet\
**Created:** [January 3, 2022, 2:13pm UTC](https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774 "2022-01-03T14:13:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimdam\_hgs](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@jimdam\_hgs](https://community.sonarsource.com/u/jimdam_hgs)\
**Post date:** [January 3, 2022, 2:13pm UTC](https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774/1 "2022-01-03T14:13:18Z")

</div>

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)

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [January 3, 2022, 3:27pm UTC](https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774/2 "2022-01-03T15:27:54Z")

</div>

Hey there.

> [@jimdam\_hgs](#):
>
> `/d:sonar.sources=%sources%`

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

---

<div class="post-metadata">

**Author:** ![jimdam\_hgs](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@jimdam\_hgs](https://community.sonarsource.com/u/jimdam_hgs)\
**Post date:** [January 4, 2022, 7:12am UTC](https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774/3 "2022-01-04T07:12:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [January 11, 2022, 7:13am UTC](https://community.sonarsource.com/t/file-filename-cs-cant-be-indexed-twice/55774/4 "2022-01-11T07:13:03Z")

</div>

Closed on January 11, 2022, 7:13am UTC

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