Deterministic build, Coverlet throws a KeyNotFoundException when ContinuousIntegrationBuild = true.
See original GitHub issueHello, 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:
- Created 3 years ago
- Reactions:1
- Comments:20 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
There are two issues that 300 fixed:
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?