I'm facing the issue that a .Net Core WPF application automatically opens a console window when started. This only happens when build inside a Docker container. When I build it directly on my PC, only the actual application window opens.
My best guess is that this is an issue with the operating system the .Net Core image is based on. The .Net Core SDK Docker Hub Repo knows the following tags: 3.1-nanoserver-1809, 3.1-nanoserver-1903, 3.1-nanoserver-1909, 3.1-nanoserver-2004, 3.1-nanoserver-2009. I was able to confirm the issue with the first three tags, but the 2004 and 2009 tags do not run on my machine, so I need someone to try this out and either confirm my theory (which would mean that it should not happen on at least on of these images) or to come up with a better explanation of why this is happening.
This is reproducible with the default .Net Core WPF app Visual Studio creates for you. Here is a Dockerfile to test it out:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . ./
RUN dotnet build -c Debug -o out
FROM stefanscherer/chocolatey
WORKDIR /app
RUN choco install -y 7zip
# Depending on your project setup it might be src/[project name]/out
COPY --from=build /src/out ./test
RUN 7z a -y test.zip ./test/*
You can build the image and extract the compiled program with the following commands:
docker build -t testimage .
docker run -d --name testcontainer testimage
docker stop testcontainer
docker cp testcontainer:app/test.zip .