【发布时间】:2021-02-19 10:04:49
【问题描述】:
在 Azure DevOps 管道中,我正在构建一个包含多个 MVC 和 API 项目的 C# 解决方案。这些项目都支持 Docker (Linux),并且解决方案中还有一个 Docker Compose 项目。 我正在运行 Linux 容器。该解决方案可以在 Visual Studio 2019 中本地构建。 Azure DevOps 中的构建失败并出现以下错误:
DockerComposeProjectBuild:
docker-compose -f "D:\a\1\s\src\docker-compose.yml" -p dockercompose11375654433676829892 --no-ansi build
Building my-app
Step 1/15 : FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
5.0-buster-slim: Pulling from dotnet/aspnet
Service 'my-app' failed to build : no matching manifest for windows/amd64 10.0.17763 in the manifest list entries
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(491,5): Error : Your Docker server host is configured for 'Windows', however the docker-compose project targets 'Linux'.
在本地,解决方案构建良好,Docker 容器也运行良好。 我的构建管道配置为使用 Windows:
pool:
vmImage: 'windows-latest'
当我切换到 ubuntu-latest 时,构建步骤立即失败:
2021-02-19T09:21:06.4937649Z ##[section]Starting: Build
2021-02-19T09:21:06.4946601Z ==============================================================================
2021-02-19T09:21:06.4947180Z Task : Visual Studio build
2021-02-19T09:21:06.4947617Z Description : Build with MSBuild and set the Visual Studio version property
2021-02-19T09:21:06.4949185Z Version : 1.166.2
2021-02-19T09:21:06.4949536Z Author : Microsoft Corporation
2021-02-19T09:21:06.4950010Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2021-02-19T09:21:06.4950534Z ==============================================================================
2021-02-19T09:21:06.5069612Z ##[error]The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.
2021-02-19T09:21:06.5083222Z ##[section]Finishing: Build
我曾尝试在解决方案属性中禁用 Docker Compose 项目的构建,但这似乎没有任何影响。
如何更改管道以解决此问题? 如果在构建过程中通过管道跳过 Docker Compose 项目也可以。
【问题讨论】:
-
您的问题进展如何?
标签: visual-studio docker-compose azure-devops .net-5