Skip to content
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

dotnet-coverage tool doesn't work inside dotnet sdk 5/6 docker container #3400

Closed
leongi opened this issue Feb 21, 2022 · 5 comments
Closed
Assignees

Comments

@leongi
Copy link

leongi commented Feb 21, 2022

Description

Unable to collect .net coverage results of .net 6 application running inside a docker container.

Steps to reproduce

Run those commands on windows with docker desktop installed:

docker run --rm -it -w /app mcr.microsoft.com/dotnet/sdk:6.0 /bin/bash
dotnet new console --no-restore
dotnet tool install --global dotnet-coverage
export PATH="$PATH:/root/.dotnet/tools"
dotnet-coverage collect -f xml -l log.txt -ll Verbose "dotnet run"

Try to read the output file:

cat output.xml

Expected behavior

Should contain coverage statistics
For example:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results>
  <modules>
    <module block_coverage="100.00" line_coverage="100.00" ...
...

Actual behavior

output.xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results />

Diagnostic logs

log.txt:

2022-02-21 19:35:07.044 +00:00 [INF] DynamicCoverageDataCollector.InitializeVanguardProvider: Initialize configuration.
2022-02-21 19:35:07.112 +00:00 [INF] Starting collection for session id: 006f305c-19e3-46fd-8d33-69eaba6c2588
2022-02-21 19:35:07.113 +00:00 [INF] ReportGenerator.LoadGenerators. OutputType: xml
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: CODE_COVERAGE_SESSION_NAME, value: 006f305c-19e3-46fd-8d33-69eaba6c2588
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: CODE_COVERAGE_PIPE_PATH, value: /tmp/006f305c-19e3-46fd-8d33-69eaba6c2588/.pipe
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: CORECLR_ENABLE_PROFILING, value: 1
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: CORECLR_PROFILER_PATH_64, value: /root/.dotnet/tools/.store/dotnet-coverage/17.2.1/dotnet-coverage/17.2.1/tools/netcoreapp3.1/any/InstrumentationEngine/ubuntu/x64/libInstrumentationEngine.so
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: CORECLR_PROFILER, value: {324F817A-7420-4E6D-B3C1-143FBED6D855}
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler, value: /root/.dotnet/tools/.store/dotnet-coverage/17.2.1/dotnet-coverage/17.2.1/tools/netcoreapp3.1/any/CodeCoverage/VanguardInstrumentationProfiler_x86.config
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler, value: /root/.dotnet/tools/.store/dotnet-coverage/17.2.1/dotnet-coverage/17.2.1/tools/netcoreapp3.1/any/InstrumentationEngine/ubuntu/x64/VanguardInstrumentationProfiler_x64.config
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: MicrosoftInstrumentationEngine_DisableCodeSignatureValidation, value: 1
2022-02-21 19:35:07.119 +00:00 [VRB] Configuring environment variable key: VANGUARD_SKIP_ENGINE_INITIALIZATION, value: 12022-02-21 19:35:07.119 +00:00 [INF] LoggerBase.Run: acquired lock. Creating new connection.
2022-02-21 19:35:07.120 +00:00 [INF] PipeConnection.Start: Creating a new pipe connection. _pipeName:/tmp/006f305c-19e3-46fd-8d33-69eaba6c2588/.pipe, platform:UbuntuX64
2022-02-21 19:35:07.127 +00:00 [INF] LoggerBase.Run: Created new connection. Number of connections: 1
2022-02-21 19:35:07.127 +00:00 [VRB] Starting process: fileName: dotnet, arguments: run
2022-02-21 19:35:07.128 +00:00 [INF] Started process id: 115
2022-02-21 19:35:09.170 +00:00 [INF] Process ID 115 exited.
2022-02-21 19:35:09.189 +00:00 [INF] PipeConnection.Stop: Closing pipe connection.
2022-02-21 19:35:09.196 +00:00 [INF] PipeConnection.OnClientConnected: starting

Environment

Windows 11 host (21H2)
Docker for desktop 4.5.1 (74721)

Tested with sdk:5.0 and sdk:6.0 - doesn't work
Also with privileged mode and with all capabilities - doesn't work
On WSL2 Ubuntu directly - works

@jakubch1
Copy link
Member

Please check this: #981 (comment)
Probably libxml2 is missing on system which is required for profiling on Linux. Try apt-get install libxml2.
This is required by CLR IE to work. Check: microsoft/CLRInstrumentationEngine#388

@leongi
Copy link
Author

leongi commented Feb 25, 2022

Thank you very much, you totally right.
It has fixed my issue.
Adding apt-get update && apt-get install libxml2 did the job.
👍

@leongi leongi closed this as completed Feb 25, 2022
@leongi
Copy link
Author

leongi commented Feb 25, 2022

Maybe it's worth to mention this missing prerequisite in the logs? I can reopen if needed.
It is also reproduced with binary output (.coverage file), so it can be little confusing.
Thanks

@jakubch1
Copy link
Member

Yes. Good idea. We will add this to log or even to output. Thanks!

@jakubch1 jakubch1 reopened this Feb 27, 2022
@jakubch1 jakubch1 added the sprint label Jun 1, 2022
@jakubch1 jakubch1 self-assigned this Jun 1, 2022
@jakubch1
Copy link
Member

jakubch1 commented Jun 3, 2022

We added information about dependencies to logs and console in version: https://dev.azure.com/dnceng/public/_artifacts/feed/test-tools/NuGet/dotnet-coverage/overview/17.3.3-beta.22303.2

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

No branches or pull requests

3 participants