简体   繁体   中英

wix burn custom UI run silent overwriting default properties

I created 2 simple wix msi's and bundled them into a burn installer. Disliking the default UI from burn I found Andrei Mușat's awesome example of a custom UI here: Custom BURN UI

I'd like to run this in silent mode In the UI Bootstrapper, the Run cmd:

    protected override void Run()
    {
        Engine.Log(LogLevel.Verbose, "Entry point of WiX - Run method");
        using (var container = SetupCompositionContainer())
        {
            bootstrapperBundleData = new BootstrapperBundleData();                
            Engine.Log(LogLevel.Verbose, JsonConvert.SerializeObject(bootstrapperBundleData));
            
            // Create main window with associated view model
            installerUIWindow = container.GetExportedValue<Window>("InstallerUIWindow");
            installerUIWindowHandle = new WindowInteropHelper(installerUIWindow).EnsureHandle();
            Engine.Detect();                
            if (Command.Display == Display.Passive || Command.Display == Display.Full)
            {
                installerUIWindow.Show();
            }
            else{ 
                Engine.Log(LogLevel.Verbose, "Running silent mode"); 
            }
            Dispatcher.Run();
            Engine.Quit(0);
            Engine.Log(LogLevel.Verbose, "Exiting custom WPF UI.");
        }
    }

In the InstallerUIWIndowViewModel, I see this:

        InstallCommandValue = new DelegateCommand(
            () => engine.Plan(LaunchAction.Install),
            () => !Installing && Status == InstallationStatus.DetectedAbsent);

        UninstallCommandValue = new DelegateCommand(
            () => engine.Plan(LaunchAction.Uninstall),
            () => !Installing && Status == InstallationStatus.DetectedPresent);

        CancelCommandValue = new DelegateCommand(
            () => IsCancelled = true);

So how do you call the InstallCmd without showing the UI?

Thanks

That code isn't really structured for that scenario.

What I think you want to do is to only create the window if you plan on showing it, and create the view model instead if you don't (you only need to obtain the window handle if you plan on showing the window). Then, instead of calling Dispatcher.Run(); call

Dispatcher.Invoke(() =>
{
    if (installerVM.UninstallCommandValue.CanExecute())
    {
        installerVM.UninstallCommandValue.Execute();
    }
    if (installerVM.InstallCommandValue.CanExecute())
    {
        installerVM.InstallCommandValue.Execute();
    }
});

I haven't tested this, but it looks like this should do the job (or at least get you a lot closer).

Let me know how it goes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM