簡體   English   中英

如何安裝從維克斯自定義引導程序/卸載單MSI軟件包包含多個類似的MSI安裝項目的添加/刪除功能?

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

我在wix捆綁包中有2個msi,我正在使用wix 3.7的自定義引導程序。 我的安裝,卸載和取消指令完美的作品。 當我嘗試使用以下方法從捆綁中添加添加/刪除msi的功能時:

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

它不按預期工作。 我正在使用下面的代碼來檢測包

    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());
        }
    }

重新安裝后,我的UI會顯示“添加/刪除,刪除,修復,重新安裝以供下次安裝”的選項,方法是使用“我可以從捆綁包中卸載單個msi”,但下一次它不會檢測到剩余的軟件包。

如果我卸載setup2.msi,它將顯示添加/刪除屏幕,但修改按鈕處於禁用狀態;如果我卸載setup1.msi,它將要求進行全新安裝。

最后我解決這個問題,我不知道是對還是錯,但因為我已經實現了它,它工作正常,我的時間。

這是代碼

在管理的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);
        }
      }

將以下行添加到WireUpEventHandlers()函數

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

這里chkSetup1和chkSetup2值設置為True或從特征樹和SetBurnVariable功能做自定義UI假。

希望對您有所幫助。

最后我解決這個問題,我不知道是對還是錯,但因為我已經實現了它,它工作正常,我的時間。

這是托管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);
        }
      }

將以下行添加到WireUpEventHandlers()函數

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

這里chkSetup1和chkSetup2值設置為True或從特征樹和SetBurnVariable功能做自定義UI假。 希望對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM