Repository navigation
Closed
Labels
SolvedThe issue is solved and can be closedbugSomething isn't workingdocumentationskip-changelogignore PR for change.log document (release-drafter
Description
Describe the bug
When targeting net481 with coverlet.msbuild@8.0.0, a TypeInitializationException is thrown when tests are run.
To Reproduce
- Clone martincostello/sqllocaldb@369c323 on a Windows machine
- Run
build.ps1from the root of the repository.
Expected behavior
Tests pass and coverage is collected.
Actual behavior
Error: System.TypeInitializationException : The type initializer for 'Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c' threw an exception.
---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Failed MartinCostello.SqlLocalDb.Interop.WindowsRegistryTests.OpenSubKey_Returns_Null_If_Key_Not_Found [152 ms]
Error Message:
System.TypeInitializationException : The type initializer for 'Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c' threw an exception.
---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
at Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c.RecordHit(Int32 )
at MartinCostello.SqlLocalDb.Interop.WindowsRegistry.OpenSubKey(String keyName) in /_/src/SqlLocalDb/Interop/WindowsRegistry.cs:line 18
at MartinCostello.SqlLocalDb.Interop.WindowsRegistryTests.OpenSubKey_Returns_Null_If_Key_Not_Found() in /_/tests/SqlLocalDb.Tests/Interop/WindowsRegistryTests.cs:line 18
----- Inner Stack Trace -----
at Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c..cctor()
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
- Which coverlet package (collector, console, msbuild, ...) and version was used?
coverlet.msbuild@8.0.0 - Which version of .NET is the code running on?
net481 - What OS and version, and what distro if applicable? Windows 10
- What is the architecture (x64, x86, ARM, ARM64)? x64
- Do you know whether it is specific to that configuration? Yes
Additional context
None.
Reacted by Jared Parsons, Bert and Frulfump
Metadata
Metadata
Assignees
Labels
SolvedThe issue is solved and can be closedbugSomething isn't workingdocumentationskip-changelogignore PR for change.log document (release-drafter
Activity
jaredpar commentedon Feb 16, 2026
Seeing the same in my projects jaredpar/complog#329
Bertk commentedon Feb 17, 2026
Thank you for the feedback. We’ll update the README.md to include the required .NET 8.0 runtime for the test environment. Other target framework versions can still be used for the test projects.
martincostello commentedon Feb 17, 2026
So if I'm understanding correctly, .NET Framework support has been completely dropped and we have to find a completely different code coverage solution now?
Bertk commentedon Feb 17, 2026
Sorry, but this is not correct. Coverlet is designed for .NET Core projects and also supports the .NET Framework. We also have a .NET Framework test project for integration testing.
https://github.com/coverlet-coverage/coverlet/blob/master/test/coverlet.tests.projectsample.netframework/coverlet.tests.projectsample.netframework.csproj
https://dotnet.microsoft.com/en-us/platform/support/policy
https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-framework
martincostello commentedon Feb 17, 2026
OK, so I'm confused then.
You reply makes it sound like a docs issue regarding the minimum supported version, not a bug, but my test project multi-targets with net10.0 and net481.
I don't see how that doesn't meet the minimum runtime requirement?
netfx support just seems broken in 8.0.0.
Bertk commentedon Feb 17, 2026
Kindly install the .NET 8.0 SDK on your test system and execute the tests without changing the target framework. Coverlet depends on the .NET 8.0 base class libraries to run successfully.
martincostello commentedon Feb 17, 2026
So it needs exactly .NET 8, and doesn't work if only .NET 9 or 10 installed? That's particularly confusing for .NET Framework support and when it works fine with only the .NET 10 SDK installed on Linux and macOS.
If that's the case, that's a bug IMHO as it should work with all currently supported versions of .NET.
Update README.md to specify .NET 8.0 SDK requirement for coverlet.msb…
jaredpar commentedon Feb 17, 2026
Can you elaborate a bit on why the .NET 8 SDK is required for .NET Framework testing. Do you all do some kind of shell out to another process here? Or use tools from the .NET 8 SDK?
Bertk commentedon Feb 18, 2026
The requirement for the .NET 8 SDK comes from the fact that coverlet.msbuild v8.0.0 depends on several Microsoft.Extensions.* packages version 8.0.0.x (which are part of .NET 8 LTS). These dependencies are internal and not directly exposed, which is why the SDK requirement may not be immediately obvious.
Coverlet v8.0.0 is also the first version to support multiple target frameworks. At the moment, coverlet.msbuild targets net8.0 and netstandard2.0. These represent the minimum supported .NET runtime frameworks for execution.
To answer your question more directly:
There is no special “shelling out” behavior involved. The dependency on the .NET 8 SDK is driven by the underlying package and runtime requirements rather than invoking separate external tools from the SDK.
Additionally, a new package — coverlet.MTP — will be released soon once some deployment issues are resolved. This will be a Microsoft Testing Platform extension and is planned to support newer runtimes, including .NET 10.
(see https://github.com/Bertk/coverlet-examples)
I hope this helps clarify things, and please feel free to ask if you’d like more details.
45 remaining items
Bump coverlet.collector and GitVersion.MsBuild (#67)
Bump coverlet.collector from 6.0.4 to 8.0.1 (#45)
deps: bump coverlet.collector from 6.0.4 to 8.0.1 (#411)
Bump coverlet.collector from 8.0.0 to 8.0.1 (#61)
Bump coverlet.collector from 6.0.4 to 8.0.1 (#32)
deps: Bump coverlet.msbuild from 6.0.4 to 8.0.1 (#14)
Bump coverlet.collector from 6.0.2 to 8.0.1 (#24)
deps: Bump coverlet.collector from 6.0.4 to 8.0.1 (#13)
build: Bump coverlet.collector from 8.0.0 to 8.0.1 (#141)
Bump the dotnet-dependencies group with 5 updates (#167)
Bump coverlet.collector from 6.0.4 to 10.0.0 (#67)
Bump coverlet.collector from 6.0.4 to 10.0.0 (#91)
Bump the nuget-packages group with 4 updates (#27)
Fix Dependabot NuGet config and update packages
chore(deps): bump coverlet.collector from 6.0.4 to 10.0.0 (#74)