Problems with BackgroundImage and BannerImage

Nov 23, 2015 at 1:54 PM
Hi,

i have some problems with the path of BackgroundImage and BannerImage (WixSharp.1.0.29.0).

I created a new C# console project with VS 2013. Some code lines:
// ...

project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
                                .Add(Dialogs.Licence)
                                .Add(Dialogs.InstallDir)
                                .Add(Dialogs.Progress)
                                .Add(Dialogs.Exit);

project.SourceBaseDir = @"C:\Users\Master\Desktop\input"; //Test.exe, readme.txt,...
project.OutDir = @"C:\Users\Master\Desktop\output"; //Test.msi

project.ControlPanelInfo.ProductIcon = @"Resources\icon.ico";
// ...
project.LicenceFile = @"Resources\Licence.rtf"; 
project.BackgroundImage =  @"Resources\SetupDialog.bmp";
project.BannerImage = @"Resources\SetupBanner.bmp";
// ...
project.PreserveTempFiles = true;
The files in the "Resources" folder are included in the VS project (not in SourceBaseDir, OutDir).
My images for the background and banner are not shown in the setup dialog. The license is shown correctly.

I selected the option "Copy to Output Directory: Copy Always" in VS for all files but that does not solve the problem with the BackgroundImage/BannerImage.
After that i copied the "Resources" folder to the input and output directory and built the Test.msi again. But it did not help.

I also tried to set a absolute path:
String pathOfProgram = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Program)).Location);
project.BannerImage = System.IO.Path.Combine(pathOfProgram, @"Resources\SetupBanner.bmp");
I checked the path in generated *.wxs:
<WixVariable Id="WixUIBannerBmp" Value="C:\Users\Master\Desktop\Test\Test.Setup\bin\Debug\Resources\SetupBanner.bmp" />
...
<Binary Id="WixUI_Bmp_Banner" SourceFile="..\output\Test.dialog_banner.png" />
The path "C:\Users\Master\Desktop\Test\Test.Setup\bin\Debug\Resources\SetupBanner.bmp" is correct. A Test.dialog_banner.png is created in the output folder but it is not my image, it is the default one. hmmm... :-(

Can someone help me?
Coordinator
Nov 24, 2015 at 3:56 AM
Edited Nov 25, 2015 at 8:02 AM
The problem is caused by the project.BackgroundImage and project.BannerImage not being propagated correctly into the ManagedUI resources.

The issue #86 (https://wixsharp.codeplex.com/workitem/86) has been created. The problem is already fixed in the code base and the fix is available from Git.

Please use the following work around until the fix is available with the next release.
project.BackgroundImage = @"C:\Users\...\Resources\SetupDialog.png";
project.BannerImage = @"C:\Users\...\Resources\SetupBanner.png";

project.WixSourceGenerated += (document) =>
{
    var bins = document.FindAll("Binary");

    bins.Single(x => x.HasAttribute("Id", "WixUI_Bmp_Dialog"))
        .SetAttribute("SourceFile", project.BackgroundImage);

    bins.Single(x => x.HasAttribute("Id", "WixUI_Bmp_Banner"))
        .SetAttribute("SourceFile", project.BannerImage);
};
Nov 24, 2015 at 1:01 PM
Thank you very much! :-)