简体   繁体   中英

Project not found when running DockerFile build command on Azure DevOps

This is the Dockerfile generated by VS2017 and it works well locally.

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["MyProj/WebApi.csproj", "WebApi/"]
COPY ["MyProject.Common/MyProject.Common.csproj", "MyProj.Common/"]
RUN dotnet restore "MyProject.WebApi/MyProject.WebApi.csproj"
COPY . .
WORKDIR "/src/MyProject.WebApi"
RUN dotnet build "MyProject.WebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "MyProject.WebApi.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyProject.WebApi.dll"]

I have created a Build Pipeline under Azure DevOps to run Docker Build with these steps :

  1. Get Sources Step from Azure Repos Git
  2. Agent Job (Hosted Ubuntu 1604)
  3. Command Line script docker build -t WebApi ./MyProject.WebApi

I have this error

2019-02-01T21:30:14.3797039Z COPY failed: stat /var/lib/docker/tmp/docker-builder684976980/MyProject.WebApi/MyProject.WebApi.csproj: no such file or directory
2019-02-01T21:30:14.3910070Z ##[error]Bash exited with code '1'.
2019-02-01T21:30:14.3994657Z ##[section]Finishing: Command Line Script

Attached screenshot 在此处输入图片说明

I don't understand what I'm doing wrong. Any suggestion?

在这种情况下,错误是由于脚本在错误的目录中运行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM