下面是 Visual Studio 2022 创建的自动生成的 Dockerfile。我可以在 Docker 中调试应用程序,但无法创建 Docker 映像。每次我尝试时,我都会在底部复制错误,说它无法复制文件。相对路径不正确吗?
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["ServicePM/ServicePM.csproj", "ServicePM/"]
COPY ["../Common/MyCompany.Common/MyCompany.Common.csproj", "../Common/MyCompany.Common/"]
COPY ["../Common/MyCompany.Common.Utilities/MyCompany.Common.Utilities.csproj", "../Common/MyCompany.Common.Utilities/"]
COPY ["../BcEventHarvest/MyCompany.PartitionUpdater/MyCompany.PartitionUpdater.csproj", "../BcEventHarvest/MyCompany.PartitionUpdater/"]
COPY ["../Common/MyCompany.Data2/MyCompany.Data2.csproj", "../Common/MyCompany.Data2/"]
COPY ["../Common/MyCompany.EventCache/MyCompany.EventCache/MyCompany.EventCache.csproj", "../Common/MyCompany.EventCache/MyCompany.EventCache/"]
COPY ["../Common/MyCompany.CloudStorage/MyCompany.CloudStorage.csproj", "../Common/MyCompany.CloudStorage/"]
COPY ["../Common/Providers/CSProfiler/MyCompany.Common.Providers.CSProfiler.csproj", "../Common/Providers/CSProfiler/"]
COPY ["../Common/MyCompany.EventDataMesh/MyCompany.EventDataMesh.csproj", "../Common/MyCompany.EventDataMesh/"]
COPY ["../BcEventHarvest/BcEventHarvest/BcEventHarvest.csproj", "../BcEventHarvest/BcEventHarvest/"]
COPY ["../Common/Providers/DownloadManagement/MyCompany.Common.Providers.DownloadManagement.csproj", "../Common/Providers/DownloadManagement/"]
COPY ["../Common/Providers/ImageManagement/MyCompany.Common.Providers.ImageManagement.csproj", "../Common/Providers/ImageManagement/"]
COPY ["../Common/Providers/WebDriver/MyCompany.Common.Providers.WebDriver.csproj", "../Common/Providers/WebDriver/"]
COPY ["../BcEventHarvest/MyCompany.FileCache/MyCompany.FileCache.csproj", "../BcEventHarvest/MyCompany.FileCache/"]
COPY ["../Common/MyCompany.Data/MyCompany.Data.csproj", "../Common/MyCompany.Data/"]
RUN dotnet restore "ServicePM/ServicePM.csproj"
COPY . .
WORKDIR "/src/ServicePM"
RUN dotnet build "ServicePM.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ServicePM.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ServicePM.dll"]
这是错误
15>COPY failed: failed to resolve scoped path ..\Common\CitySpark.Common\CitySpark.Common.csproj (): evalSymlinksInScope: \\?\C:\ProgramData\Docker\tmp\Common\CitySpark.Common\CitySpark.Common.csproj is not in \\?\C:\ProgramData\Docker\tmp\docker-builder739514268. Possible cause is a forbidden path outside the build context
15>C:\dev\MyCompany\PartitionManager\ServicePM\Dockerfile : error CTC1014: Docker command failed with exit code 1.
15>C:\dev\MyCompany\PartitionManager\ServicePM\Dockerfile : error CTC1014: COPY failed: failed to resolve scoped path ..\Common\MyCompany.Common\MyCompany.Common.csproj (): evalSymlinksInScope: \\?\C:\ProgramData\Docker\tmp\Common\MyCompany.Common\MyCompany.Common.csproj is not in \\?\C:\ProgramData\Docker\tmp\docker-builder739514268. Possible cause is a forbidden path outside the build context
15>Done building project "ServicePM.csproj" -- FAILED.
========== Rebuild All: 14 succeeded, 1 failed, 0 skipped ==========```