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 :
- Get Sources Step from Azure Repos Git
- Agent Job (Hosted Ubuntu 1604)
- 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
I don't understand what I'm doing wrong. Any suggestion?