<p>My docker build is failing due to the following error:</p>

<blockquote>
  <p>COPY failed: CreateFile \?\C:\ProgramData\Docker\tmp\docker-builder117584470\Aeros.Services.Kubernetes\Aeros.Services.Kubernetes.csproj: The system cannot find the path specified.</p>
</blockquote>

<p>I am fairly new to docker and have went with the basic project template that is set up when you create a Kubernetes container project template, so I'd figure it would work out of the box, but I'm mistaken.</p>

<p>I'm having problems trying to figure out what it's attempting to due in the temp directory structure and the reason it is failing.  Can anyone offer some assistance?  I've done some searching and others have said the default docker template was incorrect in Visual Studio, but I'm not seeing any of the files being copied over to the temp directory to begin with, so figuring out what is going on is being rather problematic at the time.</p>

<p>Here is the docker file, the only thing I've added is a publishingProfile arg so I can tell it which profile to use in the Build and Publish steps :</p>

<pre><code>ARG publishingProfile

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

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["Aeros.Services.Kubernetes/Aeros.Services.Kubernetes.csproj", "Aeros.Services.Kubernetes/"]

RUN dotnet restore "Aeros.Services.Kubernetes/Aeros.Services.Kubernetes.csproj"
COPY . ./
WORKDIR "/src/Aeros.Services.Kubernetes"
RUN dotnet build "Aeros.Services.Kubernetes.csproj" -c $publishingProfile -o /app

FROM build AS publish
RUN dotnet publish "Aeros.Services.Kubernetes.csproj" -c $publishingProfile -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Aeros.Services.Kubernetes.dll"]
</code></pre>

<p>I haven't touched the yaml file, but if you need that I can provide it as well.  Again, all I've done with this is add a few NuGet packages to the project reference.  Build in VisualStudio runs fine, but the docker command:</p>

<pre><code>docker build . --build-arg publishingProfile=Release
</code></pre>

<p>is failing with the error mentioned above.</p>

<p>Can someone be so kind as to offer some enlightenment?  Thanks!</p>

<p>Edit 1:
I am executing this from the project's folder via a PowerShell command line.</p>

<p>Leandro's comments helped come across the solution.</p>

<p>So first a rundown of that COPY command, it takes two parameters, source and destination. 
 Within the template for the Dockerfile for Visual Studio, it includes the folder location of the .csproj file it is attempting to copy.  In my case, the command read as follows:</p>

<pre><code>COPY ["Aeros.Services.Kubernetes/Aeros.Services.Kubernetes.csproj", "Aeros.Services.Kubernetes/"]
</code></pre>

<p>So it is looking for my Aeros.Services.Kubernetes.csproj file in the Aeros.Services.Kubernetes project folder and copying it to the Aeros.Services.Kubernetes folder in the src folder of Docker.</p>

<p>The problem with this is that if you use the default setup, your dockerfile is included inside the project folder.  If you are executing the docker build from within the project folder, the syntax for the COPY command is actually looking in the wrong file location.  For instance, if your project is TestApp.csproj located in the TestApp project folder, and you are executing the Docker build command for the dockerfile within the same folder, the syntax for that COPY command:</p>

<pre><code>COPY ["TestApp/TestApp.csproj", "TestApp/"]
</code></pre>

<p>is actually looking for: TestApp/TestApp/TestApp.csproj.</p>

<p>The correct syntax for the COPY command in this situation should be:</p>

<pre><code>COPY ["TestApp.csproj", "TestApp/"]
</code></pre>

<p>since you are already within the TestApp project folder.</p>

<p>Another problem with the default template that may trouble some is that it doesn't copy the web files for the project either, so once you get past the COPY and dotnet restore steps, you will fail during the BUILD with a:</p>

<blockquote>
  <p>CSC : error CS5001: Program does not contain a static 'Main' method
  suitable for an entry point</p>
</blockquote>

<p>This is resolved by adding:</p>

<pre><code>COPY . ./
</code></pre>

<p>following your RUN dotnet restore command to copy your files.</p>

<p>Once these pieces have been addressed in the default template provided, everything should be functioning as expected.</p>

<p>Thanks for the help!</p>
