the command '/bin/sh -c dotnet restore ./DockerTestDebian.csproj' returned a non-zero code: 1

Viewed 5517

I created a dockerfile to build on debian 9 that should take my vscode project folder a build a docker image but I get 2 vague errors when im building my docker image. All of my files are in home/rydeb/Desktop/DockerTestDebian directory

Result of trying to build my image

 Step 1/12 : FROM microsoft/dotnet:2.0-sdk as builder
 ---> 9e06837225a4
Step 2/12 : ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
 ---> Using cache
 ---> a7abd475d0e7
Step 3/12 : RUN mkdir -p /home/rydeb/Desktop/DockerBuildStuff
 ---> Using cache
 ---> 72a293c67243
Step 4/12 : WORKDIR /home/rydeb/Desktop/DockerTestDebian
 ---> Running in 197210d0dc93
Removing intermediate container 197210d0dc93
 ---> 8b696a6350b1
Step 5/12 : COPY .  /DockerBuildStuff
 ---> d38caf512a12
Step 6/12 : WORKDIR /home/rydeb/Desktop/DockerBuildStuff/DockerTestDebian
 ---> Running in ba9d0a67d8f4
Removing intermediate container ba9d0a67d8f4
 ---> b35c16802b52
Step 7/12 : RUN dotnet restore ./DockerTestDebian.csproj
 ---> Running in 7d5dfb98591d
MSBUILD : error MSB1009: Project file does not exist.
Switch: ./DockerTestDebian.csproj
The command '/bin/sh -c dotnet restore ./DockerTestDebian.csproj' returned a non-zero code: 1

my docker file

FROM microsoft/dotnet:2.0-sdk as builder  
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

RUN mkdir -p /home/rydeb/Desktop/DockerBuildStuff  
WORKDIR /home/rydeb/Desktop/DockerTestDebian
COPY .  /DockerBuildStuff
WORKDIR /home/rydeb/Desktop/DockerBuildStuff/DockerTestDebian

RUN dotnet restore ./DockerTestDebian.csproj  
RUN dotnet publish -c release -o published -r linux-arm

FROM microsoft/dotnet:2.0.0-runtime-stretch-arm32v7

WORKDIR /root/  
COPY --from=builder /root/src/app/DockerTestDebian/published .

CMD ["dotnet", "./DockerTestDebian.dll"]
3 Answers

Comment your dotnet restore command on dockerfile

#RUN dotnet restore

In my case a Post build event to xcopy files to my project folder leads to this error.

Just remove, build and run it and the error has gone. (right click on Project -> Properties -> Build Events) Afterwards add the copy command again and everything should work normally.

Related