Docker build error in ASP.NET Core

If you face the following error while you are building your visual studio ASP.NET Core project using docker:

Your Docker server host is configured for 'Linux', however your project targets 'Windows'.

There are two solutions to make the build work with docker support:

  • Switch docker to use Windows Containers instead of Linux containers.

  • Update the configuration DockerDefaultTargetOS in the .csproj file to match the current docker container.