1

Project Structure:

Syslog.Sample --docker.Sample --Syslog.Sample 

Project "docker.Sample" -> Add Docker support. This is the content of the generated Dockerfile:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base WORKDIR /app FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["docker.Sample/docker.Sample.csproj", "docker.Sample/"] RUN dotnet restore "docker.Sample/docker.Sample.csproj" COPY . . WORKDIR "/src/docker.Sample" RUN dotnet build "docker.Sample.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "docker.Sample.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "docker.Sample.dll"] 

Run command "docker build ."

output fail context message:

failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/docker.Sample/docker.Sample.csproj" not found: not found 

help me

1
  • 1
    Looks like this line is wrong: COPY ["docker.Sample/docker.Sample.csproj", "docker.Sample/"] Commented Nov 30, 2020 at 8:18

1 Answer 1

8

This is how I made it work: change this

COPY ["docker.Sample/docker.Sample.csproj", "docker.Sample/"]

to this

COPY ["docker.Sample.csproj", "docker.Sample/"].

Remove the directory name of the csproj. For some reason the default Dockerfile created by VS is faulty.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.