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

StackOverflow https://stackoverflow.com/questions/16590057

Question

I have 2 msi in wix bundle I am using custom bootstrapper of 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:

 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.

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.

Was it helpful?

Solution 2

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

    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

   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. I hope it will help some one.

OTHER TIPS

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

    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

   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.

I hope it will help some one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top