Question

While playing with TestBA Bootstrapper from Bryan, first I installed 1.0.0.0. Then I incremented version to 1.0.0.1 and logged the process. Here is the part where -uninstall -quite command line was passed during upgrade:

[2870:21C0][2014-02-24T17:46:38]i300: Apply begin 
[1A44:1E54][2014-02-24T17:46:41]i360: Creating a system restore point. 
[1A44:1E54][2014-02-24T17:47:15]i361: Created a system restore point. 
[1A44:1E54][2014-02-24T17:47:15]i000: Caching bundle from: 'C:\Users\fwaheed\AppData\Local\Temp\{57a07296-0310-4628-971c-2da38aa09f25}\.be\BootstrapperSetup.exe' to: 'C:\ProgramData\Package Cache\{57a07296-0310-4628-971c-2da38aa09f25}\BootstrapperSetup.exe' 
[1A44:1E54][2014-02-24T17:47:15]i320: Registering bundle dependency provider: {57a07296-0310-4628-971c-2da38aa09f25}, version: 1.0.0.1 
[1A44:2B40][2014-02-24T17:47:16]i305: Verified acquired payload: DummyInstallationPackageId at path: C:\ProgramData\Package Cache\.unverified\DummyInstallationPackageId, moving to: C:\ProgramData\Package Cache\{F1D62AA5-E68C-4B99-A6DD-D7EAE5A1D238}v1.0.0.1\DummyInstaller.msi. 
[1A44:1E54][2014-02-24T17:47:16]i323: Registering package dependency provider: {F1D62AA5-E68C-4B99-A6DD-D7EAE5A1D238}, version: 1.0.0.1, package: DummyInstallationPackageId 
[1A44:1E54][2014-02-24T17:47:16]i301: Applying execute package: DummyInstallationPackageId, action: Install, path: C:\ProgramData\Package Cache\{F1D62AA5-E68C-4B99-A6DD-D7EAE5A1D238}v1.0.0.1\DummyInstaller.msi, arguments: ' ARPSYSTEMCOMPONENT="1" MSIFASTINSTALL="7"' 
[2870:21C0][2014-02-24T17:47:22]i319: Applied execute package: DummyInstallationPackageId, result: 0x0, restart: None 
[1A44:1E54][2014-02-24T17:47:22]i325: Registering dependency: {57a07296-0310-4628-971c-2da38aa09f25} on package provider: {F1D62AA5-E68C-4B99-A6DD-D7EAE5A1D238}, package: DummyInstallationPackageId 
[1A44:1E54][2014-02-24T17:47:22]i301: Applying execute package: {f1d57671-5e3d-4be7-908f-5a47e72737d9}, action: Uninstall, path: C:\ProgramData\Package Cache\{f1d57671-5e3d-4be7-908f-5a47e72737d9}\BootstrapperSetup.exe, arguments: '"C:\ProgramData\Package Cache\{f1d57671-5e3d-4be7-908f-5a47e72737d9}\BootstrapperSetup.exe" -uninstall -quiet -burn.related.upgrade' 
[2870:21C0][2014-02-24T17:48:54]i319: Applied execute package: {f1d57671-5e3d-4be7-908f-5a47e72737d9}, result: 0x0, restart: None 
[2870:21C0][2014-02-24T17:48:54]i399: Apply complete, result: 0x0, restart: None, ba requested restart:  No 
[2870:21C0][2014-02-24T17:48:55]i500: Shutting down, exit code: 0x0 

Problem: Instead of quietly uninstalling, it would display the Uninstall Dialog. And if I click Uninstall, it would uninstall 1.0.0.0 and then application would be upgraded to 1.0.0.1.

Question: How to make it understand its command line arguments and do the process without showing Uninstall Dialog box?

I also consulted in WixBA project from Wix 3.7 source, but its command line handling is only handling InstallFolder argument.

I would really appreciate any help, as this upgrade scenario is block my Bootstrapper project.

Thanks a bunch.

Was it helpful?

Solution

The key is to pick-up the -quiet flag and not display a UI, and instead just execute the action being requested.

This is exposed via the Bootstrapper base class using the DisplayMode property, which uses a Display enum value. Options are

public enum Display
{
  Unknown,
  Embedded,
  None,
  Passive,
  Full,
}

You can then determine which action to execute via the Command.Action value (again, in the Bootstrapper base class) which uses a LaunchAction enum. Options are:

public enum LaunchAction
{
 Unknown,
 Help,
 Layout,
 Uninstall,
 Install,
 Modify,
 Repair,

}

So, I've used a custom property I named RunningSilent to detect the modes where I should not display a UI, then utilize that as shown below:

    /// <summary>
    /// True if running in silent display mode (ie: no UI).
    /// </summary>
    public virtual bool RunningSilent
    {
        get
        {
            return (DisplayMode != Display.Full && DisplayMode != Display.Passive);
        }
    }

    protected override void Run()
    {
        if (RunningSilent)
        {
             Log("Running without UI");
             LaunchAction requestedAction = Command.Action;
             //... this is an async call, so handle it accordingly.
             Engine.Plan(requestedAction);
             //... followed by Engine.Apply();

        }
        else
        {
            Log("Showing UI window");
            //.. Run your Managed UI
        }
    }

OTHER TIPS

Thanks for the hints @John. It worked with the help of your hints. Here is what I added in Run() before launching Dialogs (The forms view) :

if (Command.Display != Display.Full && Command.Action == LaunchAction.Uninstall)
{
   //MessageBox.Show("Let's do Uninstall silentley ");
   MyViewModel.PlanAction(LaunchAction.Uninstall);
}

BTW, in my case, Command.Display was Display.Embeded, which is expected behavior.

I really appreciated your tip. Thanks again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top