I already posted this on GH but as it seems to get no attention there I will try again here.
Hi!
I cannot for the life of me figure this one out... Below are the commands I am running in my GitLab CI/CD pipeline (Docker runner):
dotnet build -c Release /p:NPMBuild=false --no-incremental
dotnet test -c Release --no-build --no-restore --collect:"XPlat Code Coverage;Format=opencover" /p:NPMBuild=false --logger:"console;verbosity=normal" --logger:"junit;LogFilePath=TestOutput\test-results.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
The NPMBuild is our custom flag, don't mind it. These commands are run inside a sonnarscanner job and the dotnet test command produces the following message:
Data collection : Unable to find a datacollector with friendly name 'Format=opencover'. Data collection : Could not find data collector 'Format=opencover'
In my Test project I have a reference to coverlet.collector 6.0.0
and Microsoft.NET.TEST.Sdk 17.6.2
. The project itself targets .NET 6 and I am using the latest dotnet-sdk-6.0
version from apt-get in the docker container running the tests.
I don't understand why the opencover collector is not found, in another place in my pipeline the same commands work for outputing cobertura format. I also tried the -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
version of the command but that worked even less. Execution stopped immediately and it gave some general message about syntax or something..
It works when running the commands locally and the opencover xml output is produced as expected.
Any ideas?
I don't know why this happened but I managed to solve it by installing the dotnet sdk and runtime manually in my docker container using the dotnet-install.sh scripts. The ubuntu package of dotnet was old, version 6.0.116 with runtimes of 6.0.16, hence why I decided to try to update it by installing dotnet manually. Now It works as expected (dotnet 6.0.411 and runtimes 6.0.19)...
A bit odd why the dotnet version would play this big of a part...? Hopefully my discoveries may help others with the same issue.