Why did my analysis fail? It failed with AZL7uxb_z7q_973Ns8s4
Along with AZMAnKeY_3toJT-dxPhl
as well
Hello @lostfields,
Thank you for your feedback.
This is the error we can see on our side (in both cases):
ERROR: File xxx/log4net.config can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
This usually means you tried to configure sonar.sources
and sonar.tests
properties (or the associated inclusions/exclusions properties) in .sonarcloud.properties
file. As mention in the error, you have to be sure that any resource is only included once as source
or test
.
In case you need more help you can send us the .sonarcloud.properties
file and we’ll take a look.
Hmm. Can’t say that makes any sense. If AZMaDb3CEVoiT8HChL-F
is the same issue I don’t know how to set it up.
It’s a dotnet project, where we have 3 projects, where two of them have log4net.config along with a project itemgroup where we have set CopyToOutputDirectory
to “Always” for log4net.config
.
├── Api
│ ├── Api.csproj
│ └── log4net.config
├── Tests
│ ├── Tests.csproj
│ └── log4net.config
├── Worker
│ ├── Worker.csproj
│ └── log4net.config
The file .sonarcloud.properties
looks like this:
# Path to sources
sonar.sources = .
sonar.exclusions = Tests/**/*
# Path to tests
sonar.tests = .
#sonar.test.exclusions =
sonar.test.inclusions = Tests/**/*
# Source encoding
#sonar.sourceEncoding=UTF-8
# Exclusions for copy-paste detection
sonar.cpd.exclusions = Tests/**/*
Hi @lostfields
The error for analysis AZMaDb3CEVoiT8HChL-F
is similar but not on the same file.
ERROR: File Tfso.License.Tests/LicenseControllerTests.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
May I ask you to try to remove the entire .sonarcloud.properties
file and see if the analysis is working as expected? We normally have a built-in mechanism for .NET projects to identify test projects.
When I remove the file and add the paths in UI it work as expected, but it feels a bit strange that we have nodejs projects working fine with .sonarcloud.properties
but .NET doesn’t.
Hello @lostfields,
The properties “sonar.sources” and “sonar.tests” are not supposed to be used for the .NET analysis (autoscan and CI analysis) - see here.
The scanner detects and sets them automatically.
In this case the error is caused because the scanner indexed them once automatically and then by setting the sonar.sources
, it’s trying to re-index them.
We updated the scanner behavior in S4NET 9.0.0 to ignore these properties, however for the SonarQube Cloud automatic analysis (in this case) S4NET 6.x.x is still used.
We’ll update the docs to make this clearer - apologies for the confusion.
Thanks and happy new year!