Azure Pipeline to build docker images fails using same docker file in Visual Studio

I’m trying to create a deployment pipeline to deploy my image to Kubernetes cluster. The first step in this process is to create an image based on the docker file. The docker file I’m using was generated from Visual Studio when I added docker support and successfully creates the image when right clicking on the docker image and selecting to create it. When I configure the Azure Pipeline, the create docker image fails as soon as it tries to build the actual solution. The previous step grabs all the sources files but then fails on the docker image creation with

[error]COPY failed: stat
/var/lib/docker/tmp/docker-builder158012929/DockerTest/DockerTest.csproj:
no such file or directory [error]/usr/bin/docker failed with return
code: 1

The following is the docker file generated from Visual studio and is referenced by the azure pipeline stage to create the docker image.

FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build WORKDIR
/src COPY [“DockerTest/DockerTest.csproj”, “DockerTest/”] RUN dotnet
restore “DockerTest/DockerTest.csproj” COPY . . WORKDIR
“/src/DockerTest” RUN dotnet build “DockerTest.csproj” -c Release -o
/app

FROM build AS publish RUN dotnet publish “DockerTest.csproj” -c
Release -o /app

FROM base AS final WORKDIR /app COPY –from=publish /app . ENTRYPOINT
[“dotnet”, “DockerTest.dll”]

enter image description here

[section]Starting: Build a container image

============================================================================== Task : Docker Description : Build, tag, push, or run Docker
images, or run a Docker command. Task can be used with Docker or Azure
Container registry. Version : 0.150.6 Author : Microsoft
Corporation Help : More
Information

============================================================================== [command]/usr/bin/docker build -f
/home/vsts/work/1/s/DockerTest/Dockerfile -t
ihacontainers.azurecr.io/dockertest:6 /home/vsts/work/1/s/DockerTest
Sending build context to Docker daemon 6.144kB

Step 1/15 : FROM
mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base
2.2-stretch-slim: Pulling from dotnet/core/runtime 743f2d6c1f65: Pulling fs layer 074da88b8de0: Pulling fs layer ac831735b47a: Pulling
fs layer 3adcc844418d: Pulling fs layer 3adcc844418d: Waiting
ac831735b47a: Download complete 743f2d6c1f65: Verifying Checksum
743f2d6c1f65: Download complete 074da88b8de0: Verifying Checksum
074da88b8de0: Download complete 3adcc844418d: Verifying Checksum
3adcc844418d: Download complete 743f2d6c1f65: Pull complete
074da88b8de0: Pull complete ac831735b47a: Pull complete 3adcc844418d:
Pull complete Digest:
sha256:066c31b113b0a20e6155d3bd8a314563c688d2ec31c11d7e551af5bc2595f30c
Status: Downloaded newer image for
mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim —>
c0f9ab44ecc1 Step 2/15 : WORKDIR /app —> Running in 6d1a5f5600dd
Removing intermediate container 6d1a5f5600dd —> 527fcebeaf1f Step
3/15 : FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
2.2-stretch: Pulling from dotnet/core/sdk c5e155d5a1d1: Pulling fs layer 221d80d00ae9: Pulling fs layer 4250b3117dca: Pulling fs layer
3b7ca19181b2: Pulling fs layer 3466298fc231: Pulling fs layer
310737d73ed1: Pulling fs layer dc981de74fae: Pulling fs layer
3b7ca19181b2: Waiting 3466298fc231: Waiting 310737d73ed1: Waiting
dc981de74fae: Waiting 4250b3117dca: Verifying Checksum 4250b3117dca:
Download complete 221d80d00ae9: Verifying Checksum 221d80d00ae9:
Download complete 3466298fc231: Verifying Checksum 3466298fc231:
Download complete c5e155d5a1d1: Verifying Checksum c5e155d5a1d1:
Download complete 3b7ca19181b2: Verifying Checksum 3b7ca19181b2:
Download complete c5e155d5a1d1: Pull complete 221d80d00ae9: Pull
complete 310737d73ed1: Verifying Checksum 310737d73ed1: Download
complete 4250b3117dca: Pull complete dc981de74fae: Verifying Checksum
dc981de74fae: Download complete 3b7ca19181b2: Pull complete
3466298fc231: Pull complete 310737d73ed1: Pull complete dc981de74fae:
Pull complete Digest:
sha256:222cc0bb0bc93875ee0f6be626b2838beea838f65e53653e07c33eb9d00b0163
Status: Downloaded newer image for
mcr.microsoft.com/dotnet/core/sdk:2.2-stretch —> e4747ec2aaff Step
4/15 : WORKDIR /src —> Running in a7ebcac87f68 Removing
intermediate container a7ebcac87f68 —> d7541674a9da Step 5/15 :
COPY [“DockerTest/DockerTest.csproj”, “DockerTest/”] COPY failed: stat
/var/lib/docker/tmp/docker-builder158012929/DockerTest/DockerTest.csproj:
no such file or directory

[error]COPY failed: stat /var/lib/docker/tmp/docker-builder158012929/DockerTest/DockerTest.csproj:

no such file or directory

[error]/usr/bin/docker failed with return code: 1

[section]Finishing: Build a container image

Source: StackOverflow