Error in cmdlet New-InstallerUserInterface (System.Drawing is not supported)

None of the New-InstallerUserInterface cmdlet parameters that deal with graphic files (.ico, .bmp, .png) is working. The error received is:

  • New-InstallerUserInterface : System.Drawing is not supported on this platform.
  • At line:1 char:1
    • New-InstallerUserInterface -TopBanner .\BannerBitmap.png
  • + CategoryInfo          : NotSpecified: (:) [New-InstallerUserInterface], PlatformNotSupportedException
    
  • + FullyQualifiedErrorId : System.PlatformNotSupportedException,PowerShellToolsPro.Cmdlets.Installer.NewInstallerUserInterface
    

I was reading that message is associated to the use of .NET Core 2

There is also a Warning, when -Eula is specified that says:
Warning - EULA specified but the file does not exist.

See below screenshot.

After running some traces I realized the problem is triggered because New-InstallerUserInterface is using System.Drawing.Bitmap to get the dimensions of the passed bitmap. It seems this module is also compiled for .NET Core and hence the error.

Perhaps using another library like System.Drawing.Common or ImageSharp can solve the problem, in the meantime I am able to use icons and bitmaps by manually modifying the WXS.

It does use System.Drawing.Common.

It looks like it works in PS7.

But not PS6.

And as you reported, not in WinPS.

PS C:\Users\adamr> F:\poshtools\PowerShellToolsPro.Cmdlets.Installer.Tests\test-installer\Installer.ps1
New-InstallerUserInterface : System.Drawing is not supported on this platform.
At F:\poshtools\PowerShellToolsPro.Cmdlets.Installer.Tests\test-installer\Installer.ps1:4 char:7
+ $UI = New-InstallerUserInterface -TopBanner "$PSScriptRoot\logo.png"
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-InstallerUserInterface], PlatformNotSupportedException
    + FullyQualifiedErrorId : System.PlatformNotSupportedException,PowerShellToolsPro.Cmdlets.Installer.NewInstallerUs
   erInterface

Seeing what I can do about that.

I switched to ImageSharp for 5.4.2. It still doesn’t work in Windows PowerShell but I’m suppressing the error for now. You should be able to add images but you won’t see the warning about the size.