gpt4 book ai didi

azure-devops - Azure DevOps 构建管道 : COPY failed: stat . 。没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-05 02:54:18 28 4
gpt4 key购买 nike

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

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

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

enter image description here

运行此管道时,当它尝试复制以下日志中记录的 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 中的存储库查看器查看的存储库中

enter image description here

这是 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 for Windows 中构建和运行此解决方案。

为什么会出现此错误?

最佳答案

尝试 setting the buildContext input of the Docker task在第 34 行到 $(Build.Repository.LocalPath)。如果您有多个 repo 协议(protocol),请尝试 $(Pipeline.Workspace)(引用:Azure Pipelines Predefined Variables)

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

关于azure-devops - Azure DevOps 构建管道 : COPY failed: stat . 。没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61856563/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com