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.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.