我尝试在持续集成期间在VSTS上发布我的单元测试,我使用docker,并且在播放发布任务时,我仍然会收到以下错误,因此 dotnet测试产生的xml文件命令无法找到。
web/
├── web/
│ └── web.csproj
│ └── Dockerfile
│
├── web.test/
│ └── web.test.csproj
│
└── web.sln
└── docker-compose.yml
└── docker-compose.override.yml
如果我在本地运行命令 docker-compose run web-tests ,则会创建一个包含预期的test-results.xml文件的tests-results文件夹。
我在VSTS上做错了什么?
代码回购:Github
我的文件夹架构:
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY web.sln ./
COPY web/web.csproj web/
COPY web.test/web.test.csproj web.test/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/web
RUN dotnet build -c Release -o /app
FROM build as test
WORKDIR /src/web.test
#RUN dotnet test
FROM build AS publish
WORKDIR /src/web
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "web.dll"]
Dockerfile(EDIT删除额外的dotnet测试命令):
version: '3.4'
services:
web:
image: web
build:
context: .
dockerfile: web/Dockerfile
web-tests:
image: web-tests
build:
context: .
dockerfile: web/Dockerfile
target: test
volumes:
- ${BUILD_ARTIFACTSTAGINGDIRECTORY:-./tests-results/}:/tests
搬运工-compose.yml:
version: '3.4'
services:
web:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "80"
web-tests:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "80"
entrypoint:
- dotnet
- test
- --logger
- trx;LogFileName=/tests/test-results.xml
搬运工-compose.override.yml:
AllowPaging