项目初始化

This commit is contained in:
zhuzhiwei
2026-11-19 10:31:19 +08:00
commit a2aba4c9b0
6 changed files with 85 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# 测试项目用 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"]