小编mem*_*aus的帖子

是什么导致 Docker 映像中出现“找不到数据收集器‘XPlat 代码覆盖率’”错误?

我正在 DevOps Server 中设置一个构建,它只是运行一个 docker 构建,运行一个容器,并从中收集测试结果。Dockerfile 使用 mcr.microsoft.com/dotnet/core/sdk:2.2 映像作为其基础,我在其上安装了 powershell。

运行基本映像并执行dotnet --version确认其上有 .NET Core 2.2.301。我的测试项目引用了 coverlet.collector 1.0.1 和 Microsoft.NET.Test.Sdk 16.1.0。从我看到的 Coverlet 文档来看,这应该足以生成测试覆盖率结果。

当我不使用 Coverlet 时,我的测试运行良好并生成预期的 trx 文件。

这是我的 dockerfile 的简化版本:

FROM myrepo/coresdk22-powershell AS build
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
USER ContainerAdministrator
# Not shown: some configuration steps using powershell
WORKDIR /app
COPY webapiapp/*.csproj ./webapiapp/
WORKDIR /app/webapiapp
RUN dotnet restore --configfile ../nuget.config
WORKDIR /app/
COPY webapiapp/. ./webapiapp/
WORKDIR /app/webapiapp
RUN dotnet publish -c Release -o …
Run Code Online (Sandbox Code Playgroud)

.net-core dockerfile coverlet

4
推荐指数
1
解决办法
3521
查看次数

标签 统计

.net-core ×1

coverlet ×1

dockerfile ×1