1
votes

In an Azure DevOps pipeline, I'm building a C# solution with several MVC and API projects. The projects all have Docker support (Linux) and there's also a Docker Compose project in the solution. I'm running Linux containers. The solution builds ok locally in Visual Studio 2019. The build in Azure DevOps fails with the following error:

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'.

Locally, the solution builds ok and the Docker container runs also fine. My build pipeline is configured to use Windows:

pool:
  vmImage: 'windows-latest'

When I switch to ubuntu-latest, the build step immediately fails:

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

I have tried to disable the build of the Docker Compose project in the solution properties, but this doesn't seem to make a difference.

How do I change the pipeline to fix this? It would also be fine if the Docker Compose project is skipped during build by the pipeline.

2
How's your issue going?Cece Dong - MSFT

2 Answers

1
votes

You are using a Windows build machine in Azure Pipelines:

pool:
  vmImage: 'windows-latest'

You are asking that Windows machine to build a Linux container:

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim

This container image wont work on Windows, as the error says:

no matching manifest for windows/amd64

You want to use Linux containers, so just use a different pool:

pool:
  vmImage: 'ubuntu-latest'
0
votes

Try to unload the docker project from visual studio and edit the project and set the value "Windows" to "DockerTargetOS".

<DockerTargetOS>Windows</DockerTargetOS>