1
votes

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 enter image description here

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

1
well, this means you are building in the wrong directory, i assume4c74356b41
Thank you @4c74356b41, I changed even the Working Directory pointing to MyProject.WebApi and now the error is about the Common project dependency.MetalMad
i suggest you start a new question for that one, please4c74356b41
Done @4c74356b41MetalMad
this is the new one with changes I have made stackoverflow.com/questions/54496114/…MetalMad

1 Answers

0
votes

In this case the error was due to the script running in the wrong directory