[wix-users] Uninstall is not working
Jon Earle
earlej at hotmail.com
Thu Sep 15 11:59:21 PDT 2016
I know why I am setting the FeatureState - because the OnPlanMsiFeature event is fired after OnPlanPackageBegin, when Plan is called. :)
My bundle.wxs has EnableFeatureSelection="yes", so that I can manage the features ( I read somewhere that it was better to do that, than try to get ADDLOCAL populated):
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<?include Config.wxi ?>
<Bundle Name="$(var.ProductName)"
Version="$(var.ProductVersion)"
Manufacturer="$(var.Manufacturer)"
UpgradeCode="5a136f5e-9be9-439f-954a-3e6869856ef0">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
<Payload SourceFile="BootstrapperCore.config" />
<Payload SourceFile="$(env.WixWPF)v3.10\WixWPF.dll" />
<Payload SourceFile="$(env.WixWPF)v3.10\WixWPF.pdb" />
<Payload SourceFile="$(var.HSMClientUI.TargetPath)" />
</BootstrapperApplicationRef>
<!-- Variable Name="ADDLOCAL" bal:Overridable="yes"/ -->
<Chain>
<PackageGroupRef Id="NetFx40Web"/>
<PackageGroupRef Id="VC15_Redist_x64" />
<PackageGroupRef Id="VC15_Redist_x86" />
<MsiPackage Id="Client_MSI"
SourceFile="Client.msi"
Compressed="yes"
ForcePerMachine="yes"
DisplayInternalUI="no"
EnableFeatureSelection="yes"
Visible="no"
Vital="yes"
DisplayName="$(var.ProductName)"
LogPathVariable="LOGPATH_PROP">
<!-- MsiProperty Name="ADDLOCAL" Value="[ADDLOCAL]"/ -->
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<util:RegistrySearch
Id="VC2015_Redist_x64_Search"
Variable="VC2015_Redist_x64_Installed"
Result="exists"
Root="HKLM"
Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64"
Win64="yes" />
<util:RegistrySearch
Id="VC2015_Redist_x86_Search"
Variable="VC2015_Redist_x86_Installed"
Result="exists"
Root="HKLM"
Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86"
Win64="yes" />
<PackageGroup Id="VC15_Redist_x64">
<ExePackage Id="vcredist2015x64"
SourceFile="$(var.RESOURCES)\vc_redist.x64.exe"
Cache="yes"
PerMachine="yes"
Vital="yes"
Compressed="yes"
InstallCommand="/repair /quiet /norestart"
DetectCondition="VC2015_Redist_x64_Installed"
Permanent="yes" />
<!-- Change to 'yes' if we want the redistributables to be uninstallable. -->
</PackageGroup>
<PackageGroup Id="VC15_Redist_x86">
<ExePackage Id="vcredist2015x86"
SourceFile="$(var.RESOURCES)\vc_redist.x86.exe"
Cache="yes"
PerMachine="yes"
Vital="yes"
Compressed="yes"
InstallCommand="/repair /quiet /norestart"
DetectCondition="VC2015_Redist_x86_Installed"
Permanent="yes" />
<!-- Change to 'yes' if we want the redistributables to be uninstallable. -->
</PackageGroup>
</Fragment>
</Wix>
Here is my code (there is another file with properties defined [the data in InstallData]) thats is not really useful to post here). Perhaps you could review and let me know what I missed?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using WixWPF;
using Wix = Microsoft.Tools.WindowsInstallerXml.Bootstrapper;
namespace ClientUI
{
public partial class MainWindow : BaseBAWindow
{
private Dictionary<string, Wix.PackageState> _packageStates = new Dictionary<string, Wix.PackageState>();
private Dictionary<string, Wix.FeatureState> _featureStates = new Dictionary<string, Wix.FeatureState> ();
private Wix.LaunchAction plannedAction = Wix.LaunchAction.Unknown;
public MainWindow()
{
#if DEBUG
if (!System.Diagnostics.Debugger.IsAttached)
{
System.Diagnostics.Debugger.Launch();
}
#endif
InitializeComponent();
InstallData = new InstallerInfo();
}
public override void OnDetectMsiFeature(WPFBootstrapperEventArgs<Wix.DetectMsiFeatureEventArgs> args)
{
if (IsValid(args))
{
_featureStates[args.Arguments.FeatureId] = args.Arguments.State;
}
}
public override void OnDetectComplete(WPFBootstrapperEventArgs<Wix.DetectCompleteEventArgs> args)
{
InstallData.IsBusy = false;
InstallData.IsInstalled = _packageStates.All(x => Wix.PackageState.Present.Equals(x.Value));
if (InstallData.IsInstalled)
{
InstallData.Using_PCI = Wix.FeatureState.Local.Equals(_featureStates["PCI"]);
InstallData.Using_Feat_SNMP = Wix.FeatureState.Local.Equals(_featureStates["PCI_SNMP"]);
}
}
public override void OnDetectPackageComplete(WPFBootstrapperEventArgs<Wix.DetectPackageCompleteEventArgs> args)
{
if (IsValid(args))
{
_packageStates[args.Arguments.PackageId] = args.Arguments.State;
}
}
private void OnButtonClick(object sender, RoutedEventArgs e)
{
InstallData.IsBusy = true;
Button btn = sender as Button;
if (btn != null && btn.Content != null && Bootstrapper != null && Bootstrapper.Engine != null)
{
switch (btn.Content.ToString().ToUpperInvariant())
{
case "INSTALL": { plannedAction = Wix.LaunchAction.Install; } break;
case "MODIFY": { plannedAction = Wix.LaunchAction.Modify; } break;
case "UNINSTALL": { plannedAction = Wix.LaunchAction.Uninstall; } break;
case "QUIT": { Close(); } break;
default: break;
}
if (plannedAction != Wix.LaunchAction.Unknown)
{
Bootstrapper.Engine.Plan(plannedAction);
}
}
else { InstallData.IsBusy = false; }
}
public override void OnPlanPackageBegin(WPFBootstrapperEventArgs<Wix.PlanPackageBeginEventArgs> args)
{
if (plannedAction == Wix.LaunchAction.Modify)
{
args.Arguments.State = Wix.RequestState.Present;
}
}
public override void OnPlanMsiFeature(WPFBootstrapperEventArgs<Wix.PlanMsiFeatureEventArgs> args)
{
if (InstallData.IsInstalled)
{
Wix.FeatureState requestedState = Wix.FeatureState.Local;
if (plannedAction == Wix.LaunchAction.Uninstall)
{
requestedState = Wix.FeatureState.Absent;
}
switch (args.Arguments.FeatureId)
{
case "PCI":
args.Arguments.State = InstallData.Using_PCI ? requestedState : Wix.FeatureState.Absent;
break;
case "PCI_SNMP":
args.Arguments.State = (InstallData.Using_PCI
&& InstallData.Using_Feat_SNMP)
? requestedState : Wix.FeatureState.Absent;
break;
}
}
}
public override void OnPlanComplete(WPFBootstrapperEventArgs<Wix.PlanCompleteEventArgs> args)
{
if (IsValid(args) && args.Arguments.Status >= 0 && Bootstrapper != null && Bootstrapper.Engine != null)
{
Bootstrapper.Engine.Apply(IntPtr.Zero);
}
else { InstallData.IsBusy = false; }
}
public override void OnApplyComplete(WPFBootstrapperEventArgs<Wix.ApplyCompleteEventArgs> args)
{
if (IsValid(args) && Wix.Result.None.Equals(args.Arguments.Result))
{
args.Cancel = true;
Bootstrapper.Engine.Detect();
}
}
public InstallerInfo InstallData { get { return (DataContext as InstallerInfo); } set { DataContext = value; } }
}
}
________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of John Cooper <JoCooper at jackhenry.com>
Sent: Thursday, September 15, 2016 5:03 PM
To: WiX Toolset Users Mailing List
Subject: Re: [wix-users] Uninstall is not working
Yes, although it depends. When you starting Plan Uninstall, what is being indicated for the desired states of the components of the bundle, and what is actually happening. I had my upgrade code messing with uninstall, and I've also seen downgrade processing interfere. I'm sure there are other ways. Once I got the blockers cleared out, Plan Uninstall worked just fine.
--
John Merryweather Cooper
Senior Software Engineer -- Integration Development Group -- Enterprise Notification Service
Jack Henry & Associates, Inc.® | Lenexa, KS 66214 | Office: 913-341-3434x431050
JoCooper at jackhenry.com
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Jon Earle
Sent: Thursday, September 15, 2016 11:59 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Uninstall is not working
The e-mail below is from an external source. Please do not open attachments or click links from an unknown or suspicious origin.
That's what was originally in place and wasn't working.
Is there anything - state, method I may not have called, etc - that could potentially block the uninstall?
Cheers!
Jon
> On Sep 15, 2016, at 12:32 PM, John Cooper <JoCooper at jackhenry.com> wrote:
>
> I leave the install states as is and just Plan Uninstall.
>
> --
> John Merryweather Cooper
> Senior Software Engineer -- Integration Development Group --
> Enterprise Notification Service Jack Henry & Associates, Inc.® |
> Lenexa, KS 66214 | Office: 913-341-3434x431050
> JoCooper at jackhenry.com
>
>
>
>
>
> -----Original Message-----
> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On
> Behalf Of Jon Earle
> Sent: Thursday, September 15, 2016 11:19 AM
> To: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
> Subject: [wix-users] Uninstall is not working
>
> The e-mail below is from an external source. Please do not open attachments or click links from an unknown or suspicious origin.
>
> I have managed to sort out many aspects of writing a custom bootstrapper. The concepts are largely still foreign (mostly in that, keeping track of the flow of all of the events is not yet second nature).
>
>
> I'm making do at the moment with a couple of columns of checkboxes to allow selection of features, with code behind to validate. Install and Modify is mostly working at the present, but, uninstall is not working at all.
>
>
> I set the launchaction to Uninstall and set each selected feature to have a state of Absent. The MSI never even seems to be launched (no log is ever created for uninstall).
>
>
> What is the proper sequence of actions and states to accomplish Uninstall?
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
> NOTICE: This electronic mail message and any files transmitted with it
> are intended exclusively for the individual or entity to which it is
> addressed. The message, together with any attachment, may contain confidential and/or privileged information.
> Any unauthorized review, use, printing, saving, copying, disclosure or
> distribution is strictly prohibited. If you have received this message
> in error, please immediately advise the sender by reply email and delete all copies.
>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
NOTICE: This electronic mail message and any files transmitted with it are intended
exclusively for the individual or entity to which it is addressed. The message,
together with any attachment, may contain confidential and/or privileged information.
Any unauthorized review, use, printing, saving, copying, disclosure or distribution
is strictly prohibited. If you have received this message in error, please
immediately advise the sender by reply email and delete all copies.
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list