Cancel Installation and Rollback using wix burn Bootstrapper UI

十年热恋 提交于 2019-12-21 21:35:00

问题


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;

and launch install by using

  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.

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.

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


回答1:


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).



来源:https://stackoverflow.com/questions/15323427/cancel-installation-and-rollback-using-wix-burn-bootstrapper-ui

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