Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BootstrapperCustomBA WiX4 is not showing MSI package's UI #1396

Closed
se opened this issue Dec 9, 2023 · 6 comments
Closed

BootstrapperCustomBA WiX4 is not showing MSI package's UI #1396

se opened this issue Dec 9, 2023 · 6 comments

Comments

@se
Copy link

se commented Dec 9, 2023

This code is from the WixSharp's Wix4 template. We have tried to show this MSI package's UI but we couldn't make it happen.

What could be the problem?

It seems it doesn't respect DisplayInternalUI = true.

Example project: https://github.com/se/wixsharp-wix4-bootstrap

We have tried many ways before post this, I'm sorry if we miss anything.

using System;
using WixSharp;
using WixSharp.Bootstrapper;

namespace WixSharpSetupBootstrapperCustomBAWiX4
{
    internal class Program
    {
        static void Main()
        {
            string productMsi = BuildMsi();

            var bootstrapper =
                new Bundle("MyProduct",
                    new MsiPackage(productMsi)
                    {
                        Id = "MyProductPackageId",
                        DisplayInternalUI = true
                    });

            bootstrapper.Version = new Version("1.0.0.0");
            bootstrapper.UpgradeCode = new Guid("aeaffa48-66a6-4ee6-97a2-87746024e4f4");

            bootstrapper.Application = new ManagedBootstrapperApplication("%this%");

            bootstrapper.Build("MyProduct.exe");
        }

        static string BuildMsi()
        {
            var project = new Project("MyProduct",
                              new Dir(@"%ProgramFiles%\My Company\My Product",
                                  new File("Program.cs")));

            project.GUID = new Guid("bfd0f215-8e51-41ee-87d4-ce70f42968f8");

            return project.BuildMsi();
        }
    }
}
@Torchok19081986
Copy link

Torchok19081986 commented Dec 11, 2023

morning, according to wix v4
Screenshot 1
It seems you need new WixInternalUIBootstrapperApplication.

@oleg-shilo
Copy link
Owner

oleg-shilo commented Dec 11, 2023

There is a problem with the template.
But I got it building and running locally.

I will share it with you the solution very shortly. So you can use it before I release the template patch

@oleg-shilo oleg-shilo added the bug label Dec 11, 2023
@oleg-shilo
Copy link
Owner

oleg-shilo commented Dec 11, 2023

Done.

OK, I am not even sure it is a problem. But it is definitely something that needs to be reflected in the template content.

The template contains the code for BA app and showing MSI UI is kinda extra. That's why I did not provide the code for displaying the UI and it creates the confusion. So first, let's fix your problem.

You can fix your project by adding this:

    public MainViewModel(ManagedBA bootstrapper)
    {
        this.IsBusy = false;
        . . .
        // code below will trigger displaying msi UI. Since you are using custom BA 
        // `MsiPackage.DisplayInternalUI` property has no impact and it is the BA who needs to trigget UI popup.
        this.Bootstrapper.PlanMsiPackage += (s, e) =>
        {
            if (e.PackageId == "MyProductPackageId")
                e.UiLevel = e.Action == ActionState.Uninstall ?
                                INSTALLUILEVEL.ProgressOnly :
                                INSTALLUILEVEL.Full;
        };

All this is quite an unfortunate side effect of the WiX4 BA hosting architecture. Thus if one is using standard BA then WixSharp can detect DisplayInternalUI and inject a "magic" attribute (bal:DisplayInternalUICondition="WixBundleAction = 6") into the bundle WXS definition.

But when user defines a custom BA the BA itself must take care about msi UI and it needs to be done from that custom C# UI code. WixSharp can no longer help.

I simply will need to ensure that it is all very clear in the documentation and the template comment.
.

@se
Copy link
Author

se commented Dec 11, 2023

It works fine with this! Thank you so much (especially bringing this project to the life!).

@se se closed this as completed Dec 11, 2023
oleg-shilo added a commit that referenced this issue Dec 11, 2023
  (Added proect validation warning for DisplayInternalUI used with custom BA; it is also reflected in `DisplayInternalUI` documentation.)
@oleg-shilo
Copy link
Owner

I have now updated the API documentation:

image

And the compiler will generate the error if DisplayInternalUI is used with custom BA:

image

The change will be available in the very next release.

@oleg-shilo
Copy link
Owner

I have also reflected our discussion here: https://github.com/oleg-shilo/wixsharp/wiki/Tips'n'Tricks#showing-msi-internal-ui-from-bootstrapper-application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants