Files
2026-11-19 10:31:19 +08:00

23 lines
999 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 测试项目用 SDK 镜像即可(dotnet test 需要 SDK,而不是 runtime)
# 注意:这里不写 `# syntax=docker/dockerfile:1`,避免额外拉取 dockerfile 前端镜像
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS test
WORKDIR /src
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 \
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
DOTNET_NOLOGO=1
# 1) 先只复制 csproj 做 restore,充分利用 Docker 层缓存
COPY TySpace.Ttc.RegressionSuite.csproj ./
RUN dotnet restore TySpace.Ttc.RegressionSuite.csproj
# 2) 再复制源码并预编译,让编译错误在 build 阶段就暴露
COPY . .
RUN dotnet build TySpace.Ttc.RegressionSuite.csproj -c Release --no-restore
# 3) 容器启动即跑测试;结果写到 /src/TestResults,可挂载出来
ENTRYPOINT ["dotnet", "test", "TySpace.Ttc.RegressionSuite.csproj", \
"-c", "Release", "--no-build", "--no-restore", \
"--logger", "trx;LogFileName=test-results.trx", \
"--results-directory", "/src/TestResults"]