Wix: Managed BA command line not effective

蹲街弑〆低调 提交于 2019-12-06 00:37:25

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
        }
    }

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!