使用 wix burn Bootstrapper UI 取消安装和回滚

问题描述:

我使用的是 Wix 3.7.我正在尝试创建安装我的 msi 的 wix 刻录引导程序.我在我的 BA UI 中添加了两个按钮,用于安装和取消.我正在使用 C# 进行 BA UI 设计.

I am using Wix 3.7. I am trying to create wix burn bootstrapper that install my msi. I have added two buttons in my BA UI for Install and Cancel. i am using C# for BA UI design.

我在安装按钮中添加了以下代码以启动安装.

I have added the follwoing code in Install button for launch installation.

  MySampleBA.Model.Engine.Detect();
  MySampleBA.hwnd = IntPtr.Zero;          
  MySampleBA.Model.Bootstrapper.PlanBegin += this.PlanBegin;
  MySampleBA.Model.Bootstrapper.DetectPackageComplete += this.DetectedPackage;
  MySampleBA.Model.Bootstrapper.DetectComplete += this.DetectComplete;
  MySampleBA.Model.Bootstrapper.PlanPackageBegin += this.PlanPackageBegin;
  MySampleBA.Model.Bootstrapper.PlanComplete += this.PlanComplete;
  MySampleBA.Model.Bootstrapper.ExecuteMsiMessage += this.ExecuteMsiMessage;
  MySampleBA.Model.Bootstrapper.ExecuteProgress += this.ApplyExecuteProgress;
  MySampleBA.Model.Bootstrapper.PlanMsiFeature += this.PlanMsiFeature;
  MySampleBA.Model.Bootstrapper.PlanPackageComplete += this.PlanPackageComplete;
  MySampleBA.Model.Bootstrapper.Progress += this.ApplyProgress;
  MySampleBA.Model.Bootstrapper.CacheAcquireProgress += this.CacheAcquireProgress;
  MySampleBA.Model.Bootstrapper.CacheComplete += this.CacheComplete;
  MySampleBA.Model.Bootstrapper.Error += this.ExecuteError;
  MySampleBA.Model.Bootstrapper.ExecutePackageComplete += this.ExecuteComplte;

并使用

  MySampleBA.Model.Engine.Plan(LaunchAction.Install);
  MySampleBA.Model.Engine.Apply(MySampleBA.hwnd);

安装工作正常.但是我在中间取消安装时遇到问题.

The installation is working fine. But i have a problem with cancel the installation at mid.

我看到了引导程序应用回滚链接.但我无法了解 IDCANCEL 以及如何通过单击按钮触发错误事件.

I saw bootstrapper application rollback link. But i can't able to get an idea about IDCANCEL and How to trigger the Error event from button click.

谁能详细告诉我如何通过单击 BA UI 中的取消按钮来停止安装?

Can anyone tell how to stop the installation by clicking cancel button which is in BA UI in detail?

许多回调(如 Progress)将为您的引导程序应用程序提供参数(如 ProgressEventArgs).在 args 对象中,您可能会看到 Result 属性.要取消,请将 Result 属性设置为 Result.Cancel.当回调返回到 Burn 引擎时,它会看到您将结果设置为取消并启动回滚过程(或在该上下文中执行任何取消意味着).

Many of the callbacks (like Progress) will provide args (like ProgressEventArgs) to your bootstrapper application. In the args object you may see a Result property. To cancel, set the Result property to Result.Cancel. When the callback returns to the Burn engine, it will see you set the result to cancel and start the rollback process (or do whatever cancel means in that context).