question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deterministic build, Coverlet throws a KeyNotFoundException when ContinuousIntegrationBuild = true.

See original GitHub issue

Hello, when I try to run Coverlet (MSBuild or VSTest integration) with UseSourceLink = true and ContinuousIntegrationBuild = true, it throws a KeyNotFoundException.

Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to get coverage result
 ---> System.Collections.Generic.KeyNotFoundException: The given key '' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Coverlet.Core.Coverage.GetSourceLinkUrl(Dictionary`2 sourceLinkDocuments, String document) in /_/src/coverlet.core/Coverage.cs:line 452
   at Coverlet.Core.Coverage.CalculateCoverage() in /_/src/coverlet.core/Coverage.cs:line 350
   at Coverlet.Core.Coverage.GetCoverageResult() in /_/src/coverlet.core/Coverage.cs:line 141
   at Coverlet.Collector.DataCollection.CoverageWrapper.GetCoverageResult(Coverage coverage) in /_/src/coverlet.collector/DataCollection/CoverageWrapper.cs:line 44
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in /_/src/coverlet.collector/DataCollection/CoverageManager.cs:line 93
   --- End of inner exception stack trace ---
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in /_/src/coverlet.collector/DataCollection/CoverageManager.cs:line 98
   at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionEnd(Object sender, SessionEndEventArgs e) in /_/src/coverlet.collector/DataCollection/CoverletCoverageCollector.cs:line 160.

Here is a very simple repository that reproduces the error. The exact commands that I use are:

dotnet test /p:CollectCoverage=true /p:UseSourceLink=true /p:ContinuousIntegrationBuild=true

and

dotnet test --collect:"XPlat Code Coverage" --settings coverlet.USL.runsettings /p:ContinuousIntegrationBuild=true

If I use ContinuousIntegrationBuild = false, everything works fine.

Context:

  • .NET Core v3.1.300+
  • coverlet.collector v1.3.0 or coverlet.msbuild v2.9.0 with patch for CoverletGetPathMap
  • Microsoft.SourceLink.GitHub v1.0.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
MarcoRossignolicommented, Jul 10, 2020

Thanks @chtoucas can repro on my local, I’ll take a look asap, sorry guys but are very busy months I’m near prod release on my daily job so you know what I mean 🙏 BTW found the issue, fix shouldn’t be so hard, confirm that the problem is that deterministic build generates “deterministic” path inside sourcelinks metada, so we need to translate also those. Dev notes https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Coverage.cs#L356

1reaction
clairernovotnycommented, Jul 13, 2020

There are two issues that 300 fixed:

  1. the need for the workarounds in for the generated files
  2. enabling the base targets to return the SourceRoot items so the coverlet target workarounds aren’t needed.

@MarcoRossignoli were you able to update coverlet to use the built-in target to get the SourceRoot items instead of requiring people to add something to their directory targets?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I do a deterministic build locally ...
csproj files (urgh!) and do this via the command line, in your CI script. add the /p:ContinuousIntegrationBuild=true argument to the dotnet pack ...
Read more >
Untitled
NET SDK projects, there is an extra property, ContinuousIntegrationBuild, to set on the build server to normalize … An introduction to deterministic builds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found