-
Notifications
You must be signed in to change notification settings - Fork 398
Description
Describe the bug
If you install Coverlet.MTP through the Visual Studio interface or dotnet add package coverlet.mtp, it will add the package as a development dependency. That looks like this in the .csproj of the project
<PackageReference Include="coverlet.MTP" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
This causes coverlet.MTP.dll to not be included as a compile reference. It is required to be a compile reference due to the TestingPlatformBuilderHook that it registers. Trying to test a project that has Microsoft.Testing.Platform.MSBuild installed will fail with the following error:
C:\Work\MVPReproduceableBug\src\MyLib.Tests\obj\Debug\net8.0\SelfRegisteredExtensions.cs(15,17): error CS0400: The type or namespace name 'Coverlet' could not be found in the global namespace (are you missing an assembly reference?)
To Reproduce
Create a .NET 8+ project (project1). Add simple addition function
Create a NUnit3 test project (project2) for project1. Create test for simple addition function
Add coverlet.MTP using preferred method (except for manually typing in the package)
Try to run tests
Expected behavior
Tests run successfully
Actual behavior
Compile time error CS0400
C:\Work\MVPReproduceableBug\src\MyLib.Tests\obj\Debug\net8.0\SelfRegisteredExtensions.cs(15,17): error CS0400: The type or namespace name 'Coverlet' could not be found in the global namespace (are you missing an assembly reference?)
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.MTP 8.0.0
* Which version of .NET is the code running on? -> .NET 8, NUnit 4.4.0, NUnit3TestAdapter 6.10
* What OS and version, and what distro if applicable? -> Windows, can be reproduced on WSL (Ubuntu 24 LTS)
* What is the architecture (x64, x86, ARM, ARM64)? -> x86
* Do you know whether it is specific to that configuration? -> Only relevant is the NuGet version of Coverlet