Must-share information (formatted with Markdown):
- Using the latest dotnet-sonarscanner version
- dotnet-sonarscanner being used in a Dockerfile
- Trying to achieve a simple code scan
I have the following directory structure in my C# project:
.
└── ProjectFolder/
├── Dockerfile
├── Solution.sln
├── Source/
│ └── ...
└── Tests/
└── ...
In my Dockerfile
, I copy over this exact structure:
WORKDIR /ProjectFolder
RUN mkdir -p Source
RUN mkdir -p Tests
COPY --from=build-env /ProjectFolder/Solution.sln Solution.sln
COPY --from=build-env /ProjectFolder/Source ./Source
COPY --from=build-env /ProjectFolder/Tests ./Tests
and then I run the following dotnet-sonarscanner
command from the base directory:
RUN /root/.dotnet/tools/dotnet-sonarscanner begin \
/k:"ProjectFolder" \
/d:sonar.login="xxxxxxxxxxxxx" \
/d:sonar.host.url="yyyyyyyy" \
/d:sonar.cs.opencover.reportsPaths=coverage.xml \
/d:sonar.exclusions=**/bin/**/*,**/obj/**/* \
/d:sonar.sources=Source \
/d:sonar.tests=Tests
And I get this error (with the accompany indexing logs):
37.85 INFO: Indexing files...
37.85 INFO: Project configuration:
37.85 INFO: Excluded sources: **/bin/**/*, **/obj/**/*
37.85 INFO: Indexing files of module 'Tests'
37.85 INFO: Base dir: /ProjectFolder/Tests
37.85 INFO: Test paths: Configuration/BasicAuthOptionsTests.cs, Configuration/HealthOpt...
37.85 INFO: Excluded sources: **/bin/**/*, **/obj/**/*
37.91 INFO: Indexing files of module 'Source'
37.91 INFO: Base dir: /ProjectFolder/Source
37.91 INFO: Source paths: Configuration/BasicAuthOptions.cs, Configuration/HealthOption...
37.91 INFO: Excluded sources: **/bin/**/*, **/obj/**/*
37.96 INFO: Indexing files of module 'Source'
37.96 INFO: Base dir: /ProjectFolder
37.96 INFO: Source paths: Source
37.96 INFO: Test paths: Tests
37.96 INFO: Excluded sources: **/bin/**/*, **/obj/**/*
...
File Source/Services/XXXXX.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
I see that the module Source
is being indexed twice. How can I prevent this? What am I doing wrong here? I’ve read most of Narrowing the focus with an analysis scope but cannot figure it out…