File XYZ can't be indexed twice

2,564 views
Skip to first unread message

shaun.wilde....@gmail.com

unread,
Dec 11, 2017, 4:34:57 AM12/11/17
to SonarQube
I have just started the move over to sonarcloud (was on sonarqube.org as an early open source project)

However, all I seem to get now is a message like the following:

[exec] ERROR: File OpenCover.Console/CrashReporter/AnonymousData.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

I've tried adding entries for sonar.sources and sonar.test but all this seems to do is move the issue to another file; I even tried sonar.exclusions as well. It is just a constant game of whack-a-mole with a slow iteration cycle. 

Why has this suddenly become a thing? Surely, if it is the same file in the same location then it should just ignore it. I don't even know why it is indexed twice as it surely isn't in two projects in my code base which makes the whole thing so damn frustrating. e.g. https://github.com/OpenCover/opencover/search?utf8=%E2%9C%93&q=AnonymousData.cs&type=


Amaury Leve

unread,
Dec 12, 2017, 10:31:26 AM12/12/17
to shaun.wilde....@gmail.com, SonarQube
Hi Shaun,

Could you please give me a bit more information:
- What's the version of the Scanner for MSBuild you are using?
- Could you share the logs of the analysis (please use /d:sonar.verbose=true during the begin step)
- Could you share the different commands (remove your token) you have been using?

I have tried on a local instance (without SonarC++) and it all worked fine.

Cheers,
Amaury

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/6d856ecd-426e-4331-885f-f9d2e06085b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Amaury Levé | SonarSource

Software Developer - .Net Team

http://sonarsource.com


Are you using SonarLint in your IDE? 

shaun.wilde....@gmail.com

unread,
Dec 12, 2017, 9:49:28 PM12/12/17
to SonarQube
Hi Amaury

1. sonar-scanner-msbuild-4.0.0.821


3. this is my command line 

    <exec program='${tools.folder}\sonarqube\cxx-runner\CxxSonarQubeMsbuidRunner.exe' 
    commandline='/m:main\opencover.sln /d:sonar.verbose=true /d:sonar.sourceEncoding=UTF-8 /d:sonar.login=${sonarqube.token} /d:sonar.host.url=https://sonarcloud.io /d:sonar.cxx.forceIncludes=sonar.h /d:sonar.cfamily.build-wrapper-output.bypass=true /x:vs17 /q:${tools.folder}\sonarqube\runner\MSBuild.SonarQube.Runner.exe /n:opencover /k:opencover /p:Configuration=release,Platform=x64,GtestRunnerTaskEnabled=false /v:"${ci.fullBuildNumber}" /d:sonar.cs.opencover.reportsPaths="${root.folder}\main\bin\release\opencovertests.xml" /d:sonar.sources="${root.folder}\main\OpenCover.Console,${root.folder}\main\OpenCover.Framework,${root.folder}\main\OpenCover.Extentions,${root.folder}\main\OpenCover.Profiler,${root.folder}\main\OpenCover.Support" /d:sonar.tests="${root.folder}\main\OpenCover.Test,${root.folder}\main\OpenCover.Test.Profiler" /d:sonar.exclusions="**\*.config"' /> <!-- ,${root.folder}\main\OpenCover.Specs /d:sonar.exclusions="**\*.config,**\*.feature" -->

shaun.wilde....@gmail.com

unread,
Dec 14, 2017, 5:29:33 PM12/14/17
to SonarQube
Hi Amaury

Do you have everything you need or do you need more information? 

The /d:sonar.sources /d:sonar.tests and /d:sonar.exclusions switches are recently new and I only added them in response to the first time I got the error message

Amaury Leve

unread,
Dec 15, 2017, 6:32:06 AM12/15/17
to shaun.wilde....@gmail.com, SonarQube
Hi Shaun,

Your command line looks weird to me but I am only used to run the scanner for msbuild through the VSTS task or directly. Looking at it, it seems like you are missing the organization parameter (/o:MY_ORG).

I did the following and managed to get the analysis to work (I am using v4.0.0.821 of the scanner for msbuild and msbuild 15):

1/ Clone opencover

2/ Go to the folder

3/ SonarQube.Scanner.MSBuild.exe begin /d:sonar.login=TOKEN /d:sonar.verbose=true /d:sonar.sourceEncoding=UTF-8 /d:sonar.host.url=https://sonarcloud.io /d:sonar.cxx.forceIncludes=sonar.h /d:sonar.cfamily.build-wrapper-output.bypass=true /n:opencover /k:opencover-ammo /o:evangelink-github /d:sonar.cs.opencover.reportsPaths="**\opencovertests.xml" /d:sonar.sources="main\OpenCover.Console,\main\OpenCover.Framework,main\OpenCover.Extentions,main\OpenCover.Profiler,main\OpenCover.Support" /d:sonar.tests="main\OpenCover.Test,main\OpenCover.Test.Profiler" /d:sonar.exclusions="**\*.config"

4/ msbuild /t:rebuild main\opencover.sln /p:Configuration=release,Platform=x64,GtestRunnerTaskEnabled=false 

5/ SonarQube.Scanner.MSBuild.exe /d:sonar.login=TOKEN

6/ It worked, here is the result: https://sonarcloud.io/dashboard?id=opencover-ammo

So I think this has to do with the tools around the scanner for msbuild that you are using.

Cheers,
Amaury


For more options, visit https://groups.google.com/d/optout.

shaun.wilde....@gmail.com

unread,
Dec 15, 2017, 4:22:43 PM12/15/17
to SonarQube
Hi Amaury

I've never needed that switch before but you are right, adding it solved my problem. Is this a new requirement? Can we improve the error message for future users?

thanks again

Amaury Leve

unread,
Dec 16, 2017, 2:36:52 AM12/16/17
to shaun.wilde....@gmail.com, SonarQube

Hi Shaun,

I am wondering if you haven't tried before the new version of SonarC# was deployed to SonarCloud because we fixed shared files on the latest release.

Regarding the error message when you don't specify the organization it is pretty clear and state that you have insufficient privileges to push to the default organization.

And finally yes you are right this is a new requirement as SonarCloud is now also a SonarQube as a service for whoever wants it (not only open source projects - except they have to pay for it)

Cheers,
Amaury Levé



For more options, visit https://groups.google.com/d/optout.

bajra...@gmail.com

unread,
Mar 15, 2018, 6:38:03 AM3/15/18
to SonarQube
Hi guys

In our company we had the same issues but only with the 7.0 version! We used the Docker image for installation.

After a long while of struggling we downgraded the server to 6.7.1 and the issues were solved.The downgraded version is also installed by a Docker image.

We also didn't use the embedded DB, instead we had a PostrgeSQL instance running.

Thanks and Merci,
Enis
Reply all
Reply to author
Forward
0 new messages