Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.4K
Views
Azure Devops Pipeline - file not found in build context

Getting an error in the Azure DevOps Pipeline:

Step 7/17 : COPY ["demo6/demo6.csproj", "demo6/"]
COPY failed: file not found in build context or excluded by .dockerignore: stat demo6/demo6.csproj: file does not exist

NOTES-run the pipeline in diagnostics mode and the .sln file exists

##[debug]cwd=/home/vsts/work/1/s
##[debug]  /home/vsts/work/1/s/demo6.sln (file)
##[debug]  /home/vsts/work/1/s/demo6/demo6.csproj (file)

I have a multi-project Asp.Net Core solution with the folder structure and projects as follows:

demo6
 |--demo6/demo6.csproj
 |--demo6.api/demo6.api.csproj

The app is demo6 which references demo6.api which is a class library.

This is in GitHub in a repository demo6. I modified the autogenerated Dockerfile to add the extra demo6/ to see if that works but no.

Appreciate any help.

Dockerfile below:

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["demo6/demo6.csproj", "demo6/"]
RUN dotnet restore "demo6/demo6.csproj"
COPY . .
WORKDIR "/src/demo6"
RUN dotnet build "demo6.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "demo6.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "demo6.dll"]

Also tried this:

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["demo6/demo6/demo6.csproj", "ddemo6/"]
RUN dotnet restore "ddemo6/demo6.csproj"
COPY . .
WORKDIR "/src/ddemo6"
RUN dotnet build "demo6.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "demo6.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "demo6.dll"]

Got this error:

Step 7/17 : COPY ["demo6/demo6/demo6.csproj", "ddemo6/"]
COPY failed: file not found in build context or excluded by .dockerignore: stat demo6/demo6/demo6.csproj: file does not exist
##[error]COPY failed: file not found in build context or excluded by .dockerignore: stat demo6/demo6/demo6.csproj: file does not exist

here's the repo structureenter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The reason of file not found error may be the relative path of the Dockerfile and the csproj are different. Try to set the Dockerfile in the root of the solution should solve your error.

Also you need to add a buildContext with the csproj folder.

buildContext: Path to the build context

Also, here is a case you can refer to.

One more possible cause of COPY failed: no source files were specified is .dockerignore file present in your workspace

Look for .dockerignore file because of docker’s CLI (command line interface) it sends context to the docker daemon to load the .dockerignore file.

If the .dockerignore file exist in the context than it might be possible there is exclude entry to ignore the build directory

# ignore or exclude build directory
*/build*
*/*/build*
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!