I have a dotnet6 UnitTest project that tests some code that uses wix. It uses the package WixToolset.Dft.WindowsInstaller (4.0.4). The code that is being tested, will use MessageBox.Show() if an exception is thrown.
The use of MessageBox.Show() results in System.Windows.Forms to be required.
When I compile and execute the code through visual studio, the tests finish without issue. But when I through my CI pipeline use a Windows Container to execute the tests, I get this error:
"System.IO.FileNotFoundException : Could not load file or assembly 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified."
I am executing other test projects in dotnet6 through the same container. And they complete ust fine.
has dotnet6.0-windows defined as <TargetFramework>. Is also has <UseWindowsForms> & <UseWPF> set to true
In the Dockerfile we are using a powershell script to download binaries, to be installed, from our artifact storage.
Here's the dockerfile for the container that executes the tests:
#start with a download stage
ARG REGISTRY="artifactory.company.com"
FROM ${REGISTRY}/crmd/artifactory-util-windows:1.0.2 AS copystage
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG TOKEN
ARG FOLDER="thirdparty-generic-upload-local/microsoft/"
RUN .\artifactoryDownload.ps1 ${Env:FOLDER}vcredist/vcredist-x64-14.29.30133.0.exe
RUN .\artifactoryDownload.ps1 ${Env:FOLDER}mssql-server/msodbcsql_17.msi
RUN .\artifactoryDownload.ps1 ${Env:FOLDER}mssql-server/MsSqlCmdLnUtils.msi
RUN .\artifactoryDownload.ps1 ${Env:FOLDER}dotnet/dotnet-sdk-6.0.402-win-x64.exe
FROM $REGISTRY/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR /
COPY --from=copystage ["vcredist-x64-14.29.30133.0.exe", "VC_redist.x64.exe"]
COPY --from=copystage ["msodbcsql_17.msi", "msodbcsql.msi"]
COPY --from=copystage ["MsSqlCmdLnUtils.msi", "MsSqlCmdLnUtils.msi"]
COPY --from=copystage ["dotnet-sdk-6.0.402-win-x64.exe", "Net6.exe"]
RUN Start-Process -Wait -FilePath .\VC_redist.x64.exe -ArgumentList '/S','/v','/qn' -passthru
RUN Start-Process -Wait -FilePath "msiexec" -ArgumentList '/i .\msodbcsql.msi','/qn','/L*v msi1.log','IACCEPTMSODBCSQLLICENSETERMS=YES' -passthru
RUN Start-Process -Wait -FilePath "msiexec" -ArgumentList '/i .\MsSqlCmdLnUtils.msi','/qn','/L*v msi2.log','IACCEPTMSSQLCMDLNUTILSLICENSETERMS=YES' -passthru
RUN Start-Process -Wait -FilePath .\Net6.exe -ArgumentList '/S','/v','/qn' -passthru
RUN rm VC_redist.x64.exe
RUN rm msodbcsql.msi
RUN rm MsSqlCmdLnUtils.msi
RUN rm Net6.exe
From my point of view, it seems as if System.Windows.Forms is for some reason not part of the Windows Container, even though dotnet6 is installed.
What am I missing here? It feels like I'm not seeing the complete picture