Failed to resolve scoped path problem

Hi there
In my Visual Studio 2019 I have a solution with 2 projects

  1. CIT Web Service (just a .NET5 Web API)
  2. DTOClasses (just a ClassLibrary, POCO classes)

Project 1 has a reference to Project 2. Project 1 is dockerized. When publish Project 1 to Docker Hub, it fails with the message:

COPY failed: failed to resolve scoped path …\DTOClasses\DTOClasses.csproj (): evalSymlinksInScope: \?\C:\ProgramData\Docker\tmp\DTOClasses\DTOClasses.csproj is not in \?\C:\ProgramData\Docker\tmp\docker-builder196013785. Possible cause is a forbidden path outside the build context

The Project 1 Dockerfile is as following:

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

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["CIT Web Service/CIT Web Service.csproj", "CIT Web Service/"]
COPY ["../DTOClasses/DTOClasses.csproj", "../DTOClasses/"]
RUN dotnet restore "CIT Web Service/CIT Web Service.csproj"
COPY . .
WORKDIR "/src/CIT Web Service"
RUN dotnet build "CIT Web Service.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "CIT Web Service.csproj" -c Release -o /app/publish

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

What can cause the problem?
Thanks

Hi there

My Visual Studio builds the project as following:

docker build -f “NNNNN\CIT Web Service\Dockerfile” --force-rm -t citwebservice --label “com.microsoft.created-by=visual-studio” --label “com.microsoft.visual-studio.project-name=CIT Web Service” “NNNN”
Sending build context to Docker daemon 9.207MB

As you may see, it uses -f parameter. How come it is still not working?
Thanks.

Do you have a solution for this Problem?