简体   繁体   English

如何安装从维克斯自定义引导程序/卸载单MSI软件包包含多个类似的MSI安装项目的添加/删除功能?

[英]How to install / uninstall single msi from wix custom bootstrapper bundle containing multiple MSIs like add/remove feature of Setup project?

I have 2 msi in wix bundle I am using custom bootstrapper of wix 3.7. 我在wix捆绑包中有2个msi,我正在使用wix 3.7的自定义引导程序。 My Install,uninstall, and cancel command works perfectly. 我的安装,卸载和取消指令完美的作品。 When I am trying to give functionality of add/remove msi from bundle using: 当我尝试使用以下方法从捆绑中添加添加/删除msi的功能时:

 this.ModifyCommand = new DelegateCommand(() => this.model.PlanAction(LaunchAction.Modify), () => this.state == InstallState.Present);    

It's not working as expected. 它不按预期工作。 I am using below code to detect package 我正在使用下面的代码来检测包

    protected void DetectPackageComplete(object sender,DetectPackageCompleteEventArgs e)
    {
        //System.Diagnostics.Debugger.Launch();

        if (e.PackageId.Equals("Setup1.msi", StringComparison.Ordinal))
        {
            this.State = e.State == PackageState.Present ? InstallState.Present : InstallState.NotPresent;
            this.model.LogMessage("Setup1.msi"+this.State.ToString());
        }

        if (e.PackageId.Equals("Setup2.msi", StringComparison.Ordinal))
        {
            this.State = e.State == PackageState.Present ? InstallState.Present : InstallState.NotPresent;
            this.model.LogMessage("Setup2.msi" + this.State.ToString());
        }
    }

After fresh install my UI shows options of Add/remove, remove, repair, reinstall for next installation by using I can uninstall single msi from my bundle but next time it not detect remaining package. 重新安装后,我的UI会显示“添加/删除,删除,修复,重新安装以供下次安装”的选项,方法是使用“我可以从捆绑包中卸载单个msi”,但下一次它不会检测到剩余的软件包。

If I unstall setup2.msi it shows add/remove screen but modify button is disable and If I uninstall setup1.msi it ask for fresh installation. 如果我卸载setup2.msi,它将显示添加/删除屏幕,但修改按钮处于禁用状态;如果我卸载setup1.msi,它将要求进行全新安装。

Finally I resolve this issue I don't know whether it is right or wrong but for the time I have implemented it and it is working fine for me. 最后我解决这个问题,我不知道是对还是错,但因为我已经实现了它,它工作正常,我的时间。

here is the code 这是代码

add following event in manged BA 在管理的BA中添加以下事件

    private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e)
    {         

        if (e.PackageId.Equals("Setup1.msi", StringComparison.Ordinal))
        {
            this.model.LogMessage("PlanPackageBegin Setup1 : " + e.State);

            string IsSetup1= this.model.BootstrapperApplication.Engine.StringVariables["chkSetup1"];

            if (IsSetup1== "True")
            {
                e.State = RequestState.Present;
            }
            else
            {
                e.State = RequestState.Absent;
            }

            this.model.LogMessage("PlanPackageBegin Setup1 : " + e.State);

        }

        if (e.PackageId.Equals("Setup2.msi", StringComparison.Ordinal))
        {
            this.model.LogMessage("PlanPackageBegin Setup2 : " + e.State);

            string IsSetup2= this.model.BootstrapperApplication.Engine.StringVariables["chkSetup2"];

            if (IsSetup2== "True")
            {
                e.State = RequestState.Present;
            }
            else
            {
                e.State = RequestState.Absent;
            }

            this.model.LogMessage("PlanPackageBegin Setup2 : " + e.State);
        }
      }

Add below line to WireUpEventHandlers() function 将以下行添加到WireUpEventHandlers()函数

   this.model.BootstrapperApplication.PlanPackageBegin +=this.PlanPackageBegin;  

here chkSetup1 and chkSetup2 values are setting to True or False from custom UI made for feature tree and SetBurnVariable function. 这里chkSetup1和chkSetup2值设置为True或从特征树和SetBurnVariable功能做自定义UI假。

I hope it will help some one. 希望对您有所帮助。

Finally I resolve this issue I don't know whether it is right or wrong but for the time I have implemented it and it is working fine for me. 最后我解决这个问题,我不知道是对还是错,但因为我已经实现了它,它工作正常,我的时间。

here is the code following event in manged BA 这是托管BA中的代码跟随事件

    private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e)
    {         

        if (e.PackageId.Equals("Setup1.msi", StringComparison.Ordinal))
        {
            this.model.LogMessage("PlanPackageBegin Setup1 : " + e.State);

            string IsSetup1= this.model.BootstrapperApplication.Engine.StringVariables["chkSetup1"];

            if (IsSetup1== "True")
            {
                e.State = RequestState.Present;
            }
            else
            {
                e.State = RequestState.Absent;
            }

            this.model.LogMessage("PlanPackageBegin Setup1 : " + e.State);

        }

        if (e.PackageId.Equals("Setup2.msi", StringComparison.Ordinal))
        {
            this.model.LogMessage("PlanPackageBegin Setup2 : " + e.State);

            string IsSetup2= this.model.BootstrapperApplication.Engine.StringVariables["chkSetup2"];

            if (IsSetup2== "True")
            {
                e.State = RequestState.Present;
            }
            else
            {
                e.State = RequestState.Absent;
            }

            this.model.LogMessage("PlanPackageBegin Setup2 : " + e.State);
        }
      }

Add below line to WireUpEventHandlers() function 将以下行添加到WireUpEventHandlers()函数

   this.model.BootstrapperApplication.PlanPackageBegin +=this.PlanPackageBegin;  

here chkSetup1 and chkSetup2 values are setting to True or False from custom UI made for feature tree and SetBurnVariable function. 这里chkSetup1和chkSetup2值设置为True或从特征树和SetBurnVariable功能做自定义UI假。 I hope it will help some one. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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