Azure DevOps 构建管道:复制失败:stat .. 没有这样的文件或目录

Azure DevOps Build Pipeline : COPY failed: stat .. no such file or directory

我有一个 VS 2019 解决方案,其中包含三个 .Net Core 3.x Web Api 项目,这些项目已签入 Git 存储库。

我通过针对我的 Azure AKS 集群的向导在 Azure DevOps 中创建了一个构建管道。

已创建以下管道 YAML 文件..

在 运行 连接此管道时,当它尝试复制以下日志中记录的 Web API 项目文件时,我收到以下异常。

Step 6/38 : COPY ["BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj", "BoundedContexts/BC1/API/"]

COPY failed: stat /var/lib/docker/tmp/docker-builder568816228/BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj: no such file or directory

该文件位于通过 Azure DevOps 中的存储库查看器查看的存储库中

这是 Azure DevOps 管道中失败的 docker 文件...

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj", "BoundedContexts/BC1/API/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventStore/NextWare.Infrastructure.EventStore.csproj", "Infrastructure/NextWare.Infrastructure.EventStore/"]
COPY ["Infrastructure/NextWare.Infrastructure/NextWare.Infrastructure.csproj", "Infrastructure/NextWare.Infrastructure/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus/NextWare.Infrastructure.EventBus.csproj", "Infrastructure/NextWare.Infrastructure.EventBus/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus.RabbitMQ/NextWare.Infrastructure.EventBus.RabbitMQ.csproj", "Infrastructure/NextWare.Infrastructure.EventBus.RabbitMQ/"]
COPY ["Infrastructure/NextWare.Infrastructure.Resilience/NextWare.Infrastructure.Resilience.csproj", "Infrastructure/NextWare.Infrastructure.Resilience/"]
COPY ["BoundedContexts/BC1/DomainExceptions/NextWare.AppBuilder.BC1.Domain.Exceptions.csproj", "BoundedContexts/BC1/DomainExceptions/"]
COPY ["BoundedContexts/SharedKernel/NextWare.AppBuilder.SharedKernel.Domain.csproj", "BoundedContexts/SharedKernel/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus.ServiceBus/NextWare.Infrastructure.EventBus.ServiceBus.csproj", "Infrastructure/NextWare.Infrastructure.EventBus.ServiceBus/"]
COPY ["BoundedContexts/BC1/Application/NextWare.AppBuilder.BC1.Application.csproj", "BoundedContexts/BC1/Application/"]
COPY ["BoundedContexts/BC1/Infrastructure/NextWare.AppBuilder.BC1.Domain.Infrastructure.csproj", "BoundedContexts/BC1/Infrastructure/"]
COPY ["BoundedContexts/BC1/Domain/NextWare.AppBuilder.BC1.Domain.csproj", "BoundedContexts/BC1/Domain/"]
COPY ["BoundedContexts/SharedServices/Domain/NextWare.AppBuilder.SharedServices.Domain.csproj", "BoundedContexts/SharedServices/Domain/"]
COPY ["BoundedContexts/SharedServices/DomainExceptions/NextWare.AppBuilder.SharedServices.Domain.Exceptions.csproj", "BoundedContexts/SharedServices/DomainExceptions/"]
COPY ["Infrastructure/NextWare.Infrastructure.WebHost/NextWare.Infrastructure.WebHost.csproj", "Infrastructure/NextWare.Infrastructure.WebHost/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus.Kafka/NextWare.Infrastructure.EventBus.Kafka.csproj", "Infrastructure/NextWare.Infrastructure.EventBus.Kafka/"]
RUN dotnet restore "BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj"
COPY . .
WORKDIR "/src/BoundedContexts/BC1/API"
RUN dotnet build "NextWare.AppBuilder.BC1.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "NextWare.AppBuilder.BC1.API.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NextWare.AppBuilder.BC1.API.dll"]

我能够在 Docker 内为 Windows 在我的本地开发环境中构建和 运行 这个解决方案。

为什么会出现此错误?

尝试setting the buildContext input of the Docker task at line 34 to $(Build.Repository.LocalPath). If you have multiple repos, try $(Pipeline.Workspace) (ref: Azure Pipelines Predefined Variables)

当我在构建上下文文件夹结构时遇到问题时,有时我只是在开始时向 ls 某些文件夹或 运行 tree 抛出一点 shell script所以我可以看到结构。