coverlet: System.BadImageFormatException when code coverage is enabled.

I am trying to add code coverage to kubernetes-client-csharp.

Desperate of not having official support from Microsoft I am giving a try to coverlet. I’ve created a feature branch from project’s master and added Coverlet (everything fine in Travis so far.

But, as soon as I enable the “/p:CollectCoverage=true”, I start receiving the following error in 80% of tests we execute:

[xUnit.net 00:00:01.7251872]       System.BadImageFormatException : [/home/travis/build/sesispla/kubernetes-client-csharp/tests/bin/Debug/netcoreapp2.0/KubernetesClient.dll] No string associated with token.

Full log from faulty TravisCI job

We’re currently invoking the code coverage with this bash script:

#!/usr/bin/env bash

# Exit on any error
set -e

# Ensure no compile errors in all projects
dotnet restore
dotnet build --no-restore

# Execute Unit tests
cd tests
dotnet test --no-restore --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
if [[ $? != 0 ]]; then
    exit 1
fi

Also happens locally with MacOS 10.12.6 High Sierra.

If I set /p:CollectCoverage=false tests passes properly in both TravisCI and locally.

Any clue on what’s going on?

Thanks you!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (2 by maintainers)

Most upvoted comments

@sesispla @queen-of-code this issue has been fixed in the latest release: https://www.nuget.org/packages/coverlet.msbuild/2.2.1, also includes your Include changes @pjanotti. Let me know if you run into any other issues

That’s great to hear @sesispla! For the relative path issue, I ran into something similar in Coveralls. You need to go into your settings and set the repo root folder