Skip to content

Coverlet can't instrument module on "net5.0" target #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EYHN opened this issue Feb 23, 2021 · 1 comment
Closed

Coverlet can't instrument module on "net5.0" target #1098

EYHN opened this issue Feb 23, 2021 · 1 comment
Labels
untriaged To be investigated

Comments

@EYHN
Copy link

EYHN commented Feb 23, 2021

This seems to be a known issue.
When I run the following command:

dotnet test /p:CollectCoverage=true

It displays the following warning and the coverage is zero. It seems that it cannot load the dll containing my code.

/var/nuget/coverlet.msbuild/3.0.3/build/coverlet.msbuild.targets(39,5): warning : [coverlet] Unable to instrument module: /home/codespace/workspace/OwnHub/OwnHub.Tests/bin/Debug/net5.0/OwnHub.dll because : AssemblyResolutionException for 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Try to add <PreserveCompilationContext>true</PreserveCompilationContext> to test projects </PropertyGroup> or pass '/p:CopyLocalLockFileAssemblies=true' option to the 'dotnet test' command-line [/home/codespace/workspace/OwnHub/OwnHub.Tests/OwnHub.Tests.csproj]

I tried add <PreserveCompilationContext>true</PreserveCompilationContext> to .csproj file. I can see that the Microsoft.Extensions.Logging.Abstractions.dll is copied to the refs folder in the output path, but the test still doesn't work.

I tried manually copy the Microsoft.Extensions.Logging.Abstractions.dll to the output directory and retesting the coverage showed up fine.

Since I see in the documentation of known issues that this issue should not happen for .NET runtime version >= 3.0, I'm wondering if this is the expected case.

@daveMueller daveMueller added the untriaged To be investigated label Feb 23, 2021
@EYHN
Copy link
Author

EYHN commented Feb 26, 2021

I upgrade Microsoft.Extensions.Logging dependency to 6.0.0-preview.1.21102.12 and problem disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged To be investigated
Projects
None yet
Development

No branches or pull requests

2 participants