Windows Desktop app in Docker

I have recently started working on running windows desktop application on docker. This windows desktop app is running on Winappdriver Appium.

In Visual studio, I’ve created Dockerfile by right clicking on the project and selecting Add ‘Docker support’. I’ve attached dockerfile and test.cs file for reference.
From visual studio I am able to build the image and start the container successfully.

I am running winappdriver.exe before running my test.
Now when I run the script from test explorer, it is running fine but looks like it is not running inside the container.

I’ve researched about Xserver which talks about windows desktop app communicating with xserver and xserver communicating to docker. Tried with xserver it didn’t worked.
How to run windows desktop app on docker? Any help will be highly appreciated!

I am unable to add my Dockerfile and Test.cs file as it says new users can 't upload docs.
Also when I am pasting both the file content here, it says new users can only post 2 links.

Dockerfile

FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["HrbsDemoWinAppDriver/NuGet.Config", "HrbsDemoWinAppDriver/"]
COPY ["HrbsDemoWinAppDriver/HrbsDemoWinAppDriver.csproj", "HrbsDemoWinAppDriver/"]
RUN dotnet restore "HrbsDemoWinAppDriver/HrbsDemoWinAppDriver.csproj"
COPY . .
WORKDIR "/src/HrbsDemoWinAppDriver"
RUN dotnet build "HrbsDemoWinAppDriver.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "HrbsDemoWinAppDriver.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HrbsDemoWinAppDriver.dll"]
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using System;
using System.Threading;
using Xunit;

namespace HrbsDemoWinAppDriver
{
    public class UnitTest1
    {
        private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
        private readonly WindowsDriver<WindowsElement> hrbsSession;

        public UnitTest1()
        {
            var appiumOptions = new AppiumOptions();
            appiumOptions.AddAdditionalCapability("app", @"C:\Program Files (x86)\HRBlock2020\Program\HRBlock2020.exe");
          
            hrbsSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
        }
        [Fact]
        public void LaunchAndGotoPersonalInformation()
        {
            hrbsSession.Manage().Window.Maximize();
            Thread.Sleep(1500);
            hrbsSession.FindElementByName("Next").Click();
            hrbsSession.FindElementByName("Activate the next time you start the program").Click();
            hrbsSession.FindElementByName("OK").Click();
        }
    }
}

The short answer here is that Windows containers don’t support desktop applications.
With that said, if your goal is to run on a Windows container to run automated UI testing, you should build your .Net image on top of the Server image. The one you’re using builds on top of the Nano Server or Server Core images. These images have a very small API set. I have a blog post covering Windows images here: Nano Server x Server Core x Server - Which base image is the right one for you? - Microsoft Community Hub