在Azure DevOps上运行DockerFile构建命令时找不到项目

时间:2019-02-02 17:18:49

标签: azure docker azure-devops dockerfile azure-pipelines

这是VS2017生成的Dockerfile,在本地运行良好。

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"]

我已经在Azure DevOps下创建了一个构建管道,以通过以下步骤运行Docker Build:

  1. 从Azure Repos Git获取源代码步骤
  2. 代理作业(托管Ubuntu 1604)
  3. 命令行脚本docker build -t WebApi ./MyProject.WebApi

我遇到此错误

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

附加的屏幕截图 enter image description here

我不明白我在做什么错。 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

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