From da1d1376953ef1c9afb32d5eee02b785e52e372e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 14 Jan 2022 21:37:24 -0600 Subject: Remove orphan compatible MSI packages. Reimplements #3190 --- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 99 +++++++++++++++ src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 135 +++++++++++++++++++++ .../IBootstrapperApplication.cs | 57 +++++++-- .../IDefaultBootstrapperApplication.cs | 22 +++- 4 files changed, 304 insertions(+), 9 deletions(-) (limited to 'src/api/burn/WixToolset.Mba.Core') diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index 34b63a50..f277425e 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -63,6 +63,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler DetectPackageBegin; + + /// + public event EventHandler DetectCompatibleMsiPackage; /// public event EventHandler DetectRelatedMsiPackage; @@ -91,6 +94,12 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanPackageBegin; + /// + public event EventHandler PlanCompatibleMsiPackageBegin; + + /// + public event EventHandler PlanCompatibleMsiPackageComplete; + /// public event EventHandler PlanPatchTarget; @@ -103,6 +112,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanPackageComplete; + /// + public event EventHandler PlannedCompatiblePackage; + /// public event EventHandler PlannedPackage; @@ -414,6 +426,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectCompatibleMsiPackage(DetectCompatibleMsiPackageEventArgs args) + { + EventHandler handler = this.DetectCompatibleMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -530,6 +555,32 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanCompatibleMsiPackageBegin(PlanCompatibleMsiPackageBeginEventArgs args) + { + EventHandler handler = this.PlanCompatibleMsiPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanCompatibleMsiPackageComplete(PlanCompatibleMsiPackageCompleteEventArgs args) + { + EventHandler handler = this.PlanCompatibleMsiPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -582,6 +633,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlannedCompatiblePackage(PlannedCompatiblePackageEventArgs args) + { + EventHandler handler = this.PlannedCompatiblePackage; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -1363,6 +1427,15 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, ref bool fCancel) + { + DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, fCancel); + this.OnDetectCompatibleMsiPackage(args); + + fCancel = args.Cancel; + return args.HResult; + } + int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); @@ -1445,6 +1518,24 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, bool recommendedRemove, ref bool pRequestedRemove, ref bool fCancel) + { + PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, recommendedRemove, pRequestedRemove, fCancel); + this.OnPlanCompatibleMsiPackageBegin(args); + + pRequestedRemove = args.RequestRemove; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanCompatibleMsiPackageComplete(string wzPackageId, string wzCompatiblePackageId, int hrStatus, bool requestedRemove) + { + PlanCompatibleMsiPackageCompleteEventArgs args = new PlanCompatibleMsiPackageCompleteEventArgs(wzPackageId, wzCompatiblePackageId, hrStatus, requestedRemove); + this.OnPlanCompatibleMsiPackageComplete(args); + + return args.HResult; + } + int IBootstrapperApplication.OnPlanPatchTarget(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { PlanPatchTargetEventArgs args = new PlanPatchTargetEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); @@ -1486,6 +1577,14 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnPlannedCompatiblePackage(string wzPackageId, string wzCompatiblePackageId, bool remove) + { + var args = new PlannedCompatiblePackageEventArgs(wzPackageId, wzCompatiblePackageId, remove); + this.OnPlannedCompatiblePackage(args); + + return args.HResult; + } + int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback, bool fPlannedCache, bool fPlannedUncache) { var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback, fPlannedCache, fPlannedUncache); diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index 93831be6..d4d70651 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -495,6 +495,37 @@ namespace WixToolset.Mba.Core public string PackageId { get; private set; } } + /// + /// Event arguments for + /// + [Serializable] + public class DetectCompatibleMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.CompatiblePackageVersion = compatiblePackageVersion; + } + + /// + /// Gets the identity of the package that was not detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package that was detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the version of the compatible package that was detected. + /// + public string CompatiblePackageVersion { get; private set; } + } + /// /// Event arguments for /// @@ -775,6 +806,80 @@ namespace WixToolset.Mba.Core public BOOTSTRAPPER_CACHE_TYPE CacheType { get; set; } } + /// + /// Event arguments for + /// + [Serializable] + public class PlanCompatibleMsiPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, bool recommendedRemove, bool requestRemove, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.CompatiblePackageVersion = compatiblePackageVersion; + this.RecommendedRemove = recommendedRemove; + this.RequestRemove = requestRemove; + } + + /// + /// Gets the identity of the package that was not detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the version of the compatible package detected. + /// + public string CompatiblePackageVersion { get; private set; } + + /// + /// Gets the recommended state to use for the compatible package for planning. + /// + public bool RecommendedRemove { get; private set; } + + /// + /// Gets or sets whether to uninstall the compatible package. + /// + public bool RequestRemove { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanCompatibleMsiPackageCompleteEventArgs : StatusEventArgs + { + /// + public PlanCompatibleMsiPackageCompleteEventArgs(string packageId, string compatiblePackageId, int hrStatus, bool requestedRemove) + : base(hrStatus) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.RequestedRemove = requestedRemove; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the requested state of the package. + /// + public bool RequestedRemove { get; private set; } + } + /// /// Event arguments for /// @@ -980,6 +1085,36 @@ namespace WixToolset.Mba.Core public RequestState Requested { get; private set; } } + /// + /// Event arguments for + /// + [Serializable] + public class PlannedCompatiblePackageEventArgs : HResultEventArgs + { + /// + public PlannedCompatiblePackageEventArgs(string packageId, string compatiblePackageId, bool remove) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.Remove = remove; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the planned state of the package. + /// + public bool Remove { get; private set; } + } + /// /// Event arguments for /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index babd523a..05f96106 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -181,17 +181,21 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectCompatibleMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + /// /// See . /// - /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectRelatedMsiPackage( @@ -317,6 +321,32 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanCompatibleMsiPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, + [MarshalAs(UnmanagedType.Bool)] bool fRecommendedRemove, + [MarshalAs(UnmanagedType.Bool)] ref bool fRequestRemove, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanCompatibleMsiPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + int hrStatus, + [MarshalAs(UnmanagedType.Bool)] bool fRequestedRemove + ); + /// /// See . /// @@ -387,6 +417,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] RequestState requested ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlannedCompatiblePackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + [MarshalAs(UnmanagedType.Bool)] bool fRemove + ); + /// /// See . /// diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index e809a965..ce06408e 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -133,6 +133,11 @@ namespace WixToolset.Mba.Core /// event EventHandler DetectBegin; + /// + /// Fired when a package was not detected but a package using the same provider key was. + /// + event EventHandler DetectCompatibleMsiPackage; + /// /// Fired when the detection phase has completed. /// @@ -268,6 +273,16 @@ namespace WixToolset.Mba.Core /// event EventHandler PlanBegin; + /// + /// Fired when the engine plans a new, compatible package using the same provider key. + /// + event EventHandler PlanCompatibleMsiPackageBegin; + + /// + /// Fired when the engine has completed planning the installation of a specific package. + /// + event EventHandler PlanCompatibleMsiPackageComplete; + /// /// Fired when the engine has completed planning the installation. /// @@ -278,6 +293,11 @@ namespace WixToolset.Mba.Core /// event EventHandler PlanForwardCompatibleBundle; + /// + /// Fired when the engine has completed planning a compatible package. + /// + event EventHandler PlannedCompatiblePackage; + /// /// Fired when the engine has completed planning a package. /// @@ -399,4 +419,4 @@ namespace WixToolset.Mba.Core /// event EventHandler UnregisterComplete; } -} \ No newline at end of file +} -- cgit v1.2.3-55-g6feb