-
Notifications
You must be signed in to change notification settings - Fork 387
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
Unable to instrument module incl. simple sample - no work around #1459
Comments
OK - so I was copying the wrong DLL ( cp webapp/bin/Debug/net7.0/refs/Microsoft.AspNetCore.Mvc.Razor.dll xunit-tests/bin/Debug/net7.0 That does allow coverage to be collected. Is this still the required / recommended solution? Is there any way to automate this w/ MSBuild? |
FWIW, adding the following to the xUnit <!--
Begin fix / work around for error(s) generating code coverage using e.g. Coverlet or AltCover.
See: https://github.com/coverlet-coverage/coverlet/issues/1459
See: https://github.com/SteveGilham/altcover/issues/179
-->
<PropertyGroup>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
</PropertyGroup>
<Target Name="CopyReferencedAssemblies" AfterTargets="Build">
<ItemGroup>
<ReferencedAssemblies Include="$(OutputPath)refs/*.dll"/>
</ItemGroup>
<Copy SourceFiles="@(ReferencedAssemblies)" DestinationFolder="$(OutputPath)" ContinueOnError="false" />
</Target>
<!-- End fix / work around for error(s) generating code coverage using e.g. Coverlet or AltCover. --> |
Again FWIW, I was able to reproduce this w/ AltCover and the author was able to remedy it with a source code fix, in case that helps with your library as well. |
Hello there! I hope this is not just noise as this seems like a fairly common issue. In fact I've reported it in the past and was able to work around the issue years ago.
However, today on another project, I have run into it again and none of the reported workarounds (
.csproj
settings, command line parameters, copying DLLs) seem to work..NET Version
Steps to Reproduce
Execute from CLI:
Add the following class to the web application project:
Add the following class to the xUnit project:
Execute from the CLI:
dotnet test /p:CollectCoverage=true
Expected Result
Actual Result
Attempted Work Arounds
I have tried the recommended work arounds such as:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
to the.csproj
file(s)<PreserveCompilationContext>true</PreserveCompilationContext>
to the.csproj
file(s)/p:CopyLocalLockFileAssemblies=true
command line argumentwebapp/bin/Debug/net7.0/refs/Microsoft.AspNetCore.Razor.dll xunit-tests/bin/Debug/net7.0
Unfortunately none of these resolve the issue.
The text was updated successfully, but these errors were encountered: