ines touzi
ines touzi

Reputation: 51

Dotnet : Dockerfile No such file or directory

I don't understand what's exactly the issue is. I am trying to dockerize my orchard web app. But I always have this issue of no such file or directory, but when I try to ls into this directory i can clearly see my .csproj Here is my dockerfile:

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

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
RUN mkdir p FGIC.WebCMS
COPY FGIC.WebCMS/FGIC.WebCMS.csproj FGIC.WebCMS/.
RUN dotnet restore FGIC.WebCMS/FGIC.WebCMS.csproj
COPY . .
RUN ls -al /src
RUN ls -al /src/FGIC.WebCMS
WORKDIR /src/FGIC.WebCMS
RUN dotnet build FGIC.WebCMS.csproj -c Release -o /app/build

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

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

This is the error that appear in the layer of building the docker image

  WebCompiler: Begin compiling compilerconfig.json
  WebCompiler installing updated versions of the compilers...
 /root/.nuget/packages/buildwebcompiler/1.12.394/build/BuildWebCompiler.targets(12,9): error : No such file or directory [/src/FGIC.WebCMS/FGIC.WebCMS.csproj]

Build FAILED.

/root/.nuget/packages/buildwebcompiler/1.12.394/build     /BuildWebCompiler.targets(12,9): error : No such file or directory [/src/FGIC.WebCMS/FGIC.WebCMS.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:06.37
The command '/bin/sh -c dotnet build FGIC.WebCMS.csproj -c Release -o /app/build' returned a non-zero code: 1

And this is the structure of my app folder:

|-- Dockerfile
|--FGIC.sln
|--FGIC.WebCMS/ --|FGIC.WebCMS/FGIC.WebCMS.csproj
                --| other files of the project

Upvotes: 1

Views: 1112

Answers (2)

ines touzi
ines touzi

Reputation: 51

It was a problem in the csproj file. It contains this line:

    <PackageReference Include="BuildWebCompiler" Version="1.12.394" />

So after deleting this line, everything works right.

Upvotes: 4

Shirosamus
Shirosamus

Reputation: 126

Can you try this in the second part, please ? Seems like a directory problem.

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . .
RUN dotnet restore FGIC.WebCMS/FGIC.WebCMS.csproj
RUN ls -al /FGIC.WebCMS
RUN dotnet build FGIC.WebCMS/FGIC.WebCMS.csproj -c Release -o /app/build

Upvotes: 0

Related Questions