c# - 由于 COPY --from=build 导致 Azure Pipeline 上的 Docker 构建失败
问题描述
大家好,我无法在 azure build 管道中获取 COPY --from=build /src /dest 。虽然它在我的本地工作......请参阅下面的代码
Dockerfile
#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/framework/sdk:4.7.2-windowsservercore-ltsc2019 AS build
WORKDIR /src
COPY . .
COPY SimpleWeb/*.csproj ./SimpleWeb/
COPY SimpleWeb/*.config ./SimpleWeb/
RUN nuget restore
COPY SimpleWeb/. ./SimpleWeb/
WORKDIR /src/SimpleWeb
RUN msbuild /p:Configuration=Release
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2019 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /src/SimpleWeb/bin/Release/Publish/. .
Azure Pipeline.yml
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: Docker@2
displayName: Build
inputs:
containerRegistry: 'container-registry-dockerhub'
repository: 'myrepo'
command: 'build'
Dockerfile: '**/Dockerfile'
tags: 'latest'
- task: Docker@2
displayName: Push
inputs:
containerRegistry: 'container-registry-dockerhub'
repository: 'myrepo'
command: 'push'
tags: 'latest'
来自 Azure CI 构建的错误
Step 12/21 : COPY --from=build /src/SimpleWeb/bin/Release/Publish/. .
COPY failed: CreateFile \\?\Volume{a4952e14-500f-4d78-9efe-1a9e638e3459}\src\SimpleWeb\bin\Release\Publish: The system cannot find the path specified.
##[error]The process 'C:\Program Files\Docker\docker.exe' failed with exit code 1
------ EDITED----- 这虽然有效:
复制 --from=build /src/SimpleWeb/。.
我不确定为什么Azure Pipeline 上没有生成bin/Release/Publish
解决方案
您可以尝试使用dotnet restore
而不是nuget restore
.
nuget restore
会将所有 NuGet 依赖项下载到您的项目中。
dotnet restore
将下载所有 NuGet 依赖项以及参考和工具。
推荐阅读
- python - 使用 setUpTestData 的 Django 测试不会保留测试之间的更改
- python - 在写入 laspy 文件时定义新维度
- c - 在c中的另一个函数中分配结构
- java - 子字符串字符串直到第一个字母
- mysql - 使用单个查询更新两个表
- python - Django 项目模板错误:django.template.exceptions.TemplateDoesNotExist
- google-chrome - 使用支持悬停的输入类型启动无头 Chrome
- jpa - jpa控制器和级联删除问题
- java - 使用不同的 log4j 配置(设置为调试)重新运行失败的测试?
- javascript - 是否可以使用 PHP、Javascript 跟踪我的网站用户的确切位置