dotnet-coverlet

Configure coverlet code coverage drivers for .NET test projects and CI pipelines.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-coverlet-zhenpenglai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-coverlet
Source: https://github.com/zhenpengLai/myuseskill/tree/main/dotnet-coverlet
Command: npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-coverlet-zhenpenglai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up code coverage in .NET projects requires choosing between three coverlet drivers (collector, MSBuild, console), configuring exclusions, and producing CI-safe commands, which is error-prone without guidance. ## Core Features & Use Cases - Driver Selection: Chooses between coverlet.collector for VSTest, coverlet.msbuild for property-driven runs, and coverlet.console for standalone scenarios, ensuring only one driver per test project. - Bootstrap & Detection: Detects existing coverage configuration in csproj/props/targets files and installs the correct driver with reproducible local and CI commands. - Filtering & Thresholds: Provides exclusion patterns for generated code, EF migrations, and test assemblies, plus coverage thresholds and ReportGenerator integration. - Use Case: A team needs branch coverage in GitHub Actions for their .NET solution; this skill detects the runner model, adds coverlet.collector to test projects, and records the exact dotnet test --collect:"XPlat Code Coverage" command in AGENTS.md. ## Quick Start Ask the assistant to add Coverlet coverage to your .NET solution and choose the right driver for your CI pipeline.

Frequently Asked Questions about dotnet-coverlet

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add code coverage to a .NET test project?▼

Add the coverlet.collector package to your test project and run dotnet test with --collect:"XPlat Code Coverage". Coverage files are written to the TestResults directory in cobertura format by default.

What is the difference between coverlet.collector, coverlet.msbuild, and coverlet.console?▼

coverlet.collector integrates with VSTest via --collect, coverlet.msbuild uses MSBuild properties like /p:CollectCoverage=true, and coverlet.console is a standalone CLI tool. Choose exactly one driver per test project and never mix collector and msbuild together.

How do I exclude generated code and migrations from .NET coverage?▼

Use ExcludeByFile with patterns like **/Migrations/*.cs and ExcludeByAttribute with GeneratedCodeAttribute or ExcludeFromCodeCoverage. Filter expressions like [*]*.Migrations.* exclude assemblies and types by namespace.

Can coverlet enforce a minimum coverage threshold in CI?▼

Yes, the MSBuild driver supports /p:Threshold=80 with ThresholdType of line, branch, or method, failing the build when coverage drops below the limit. ThresholdStat can be set to minimum, total, or average.

When should I not use coverlet for .NET coverage?▼

Do not use coverlet when the repository has already standardized on a different coverage engine. It is also not intended for rendering coverage reports by itself; pair it with ReportGenerator when humans need HTML output.