2

I wrote the following multi-stage build in a Dockerfile to both build and run an image for a .NET Framework console application:

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS build
WORKDIR /app
COPY . .
RUN nuget restore MySolution.sln
WORKDIR /app/MyProject
RUN msbuild /p:Configuration=Release /p:Platform=AnyCPU
RUN echo $(ls ./)

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 AS runtime
WORKDIR /output
COPY --from=build /app/MyProject/bin .
RUN echo $(ls ./)
ENTRYPOINT ["MyProject.exe"]

So far, so good and Docker builds the image. However, when I run it inside a container, Docker fails with the following error:

docker: Error response from daemon: container 75c0daf4796521dbb38016148a145d6b6bc70fb7cd3931e5c0c5c1232d972329 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF7CE419F4B: (caller: 00007FF7CE3CE13A) Exception(2) tid(390) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000].

I think the error is due to the fact that the second stage of the Dockerfile isn’t doing what it should be. In fact, when the parser arrives to the first RUN echo $(ls ./), it correctly prints out the list of items included in the /app/ProjectFolder folder, with the bin and obj folders created by the build process (that is, the first stage of the Dockerfile). However, the second RUN echo $(ls ./) command just prints out this:

...
Step 12/13 : RUN echo $(ls ./)
 ---> Running in 1822187d8a21
$(ls ./)
...

So, it doesn’t even find the MyProject.exe file to be executed. What am I doing wrong?

Pine Code
  • 2,466
  • 3
  • 18
  • 43

1 Answers1

0

Can you try to build your application before to get the dll (msbuild step) on the bin folders. And then docker build again.