From 0d3d54992104288e9ee0c834d0b96e8502fd2d42 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 11 Jan 2024 18:26:20 -0800 Subject: Move the BootstrapperApplication out of proc --- .../BaseBootstrapperApplicationFactory.cs | 48 +++---- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 149 ++++++++++----------- .../BootstrapperApplicationFactoryAttribute.cs | 18 +-- .../WixToolset.Mba.Core/BootstrapperCommand.cs | 44 ++++++ src/api/burn/WixToolset.Mba.Core/BundleInfo.cs | 8 +- src/api/burn/WixToolset.Mba.Core/Engine.cs | 4 +- src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 91 +++++++------ .../IBootstrapperApplication.cs | 38 +++--- .../IBootstrapperApplicationFactory.cs | 54 +------- .../WixToolset.Mba.Core/IBootstrapperEngine.cs | 9 +- src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs | 11 +- .../IDefaultBootstrapperApplication.cs | 20 +-- src/api/burn/WixToolset.Mba.Core/IEngine.cs | 3 +- .../ManagedBootstrapperApplication.cs | 19 +++ src/api/burn/WixToolset.Mba.Core/MbaNative.cs | 10 +- src/api/burn/WixToolset.Mba.Core/PackageInfo.cs | 6 +- 16 files changed, 269 insertions(+), 263 deletions(-) create mode 100644 src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs (limited to 'src/api/burn/WixToolset.Mba.Core') diff --git a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 339bfd8f..25995e27 100644 --- a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -6,58 +6,48 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; /// - /// Default implementation of . + /// This is no longer used. /// + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { /// - /// Default implementation of + /// This is no longer used. /// - /// The args struct given by the engine when initially creating the BA. - /// The results struct given by the engine when initially creating the BA + /// This is no longer used. + /// This is no longer used. public void Create(IntPtr pArgs, IntPtr pResults) { - InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); - - var ba = this.Create(engine, bootstrapperCommand); - StoreBAInCreateResults(pResults, ba); + throw new NotImplementedException(); } /// - /// Called by to get the . + /// This is no longer used. /// - /// The bundle engine. - /// Command information passed from the engine for the BA to perform. - /// The for the bundle. + /// This is no longer used. + /// This is no longer used. + /// This is no longer used. protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); /// - /// Initializes the native part of . - /// Most users should inherit from instead of calling this method. + /// This is no longer used. /// - /// The args struct given by the engine when initially creating the BA. - /// The bundle engine interface. - /// The context of the current run of the bundle. + /// This is no longer used. + /// This is no longer used. + /// This is no longer used. public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) { - Command pCommand = new Command - { - cbSize = Marshal.SizeOf(typeof(Command)) - }; - var pEngine = MbaNative.InitializeFromCreateArgs(pArgs, ref pCommand); - engine = new Engine(pEngine); - bootstrapperCommand = pCommand.GetBootstrapperCommand(); + throw new NotImplementedException(); } /// - /// Registers the BA with the engine using the default mapping between the message based interface and the COM interface. - /// Most users should inherit from instead of calling this method. + /// This is no longer used. /// - /// The results struct given by the engine when initially creating the BA - /// The . + /// This is no longer used. + /// This is no longer used. public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) { - MbaNative.StoreBAInCreateResults(pResults, ba); + throw new NotImplementedException(); } } } diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index a0ec6ab9..98b34217 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -12,24 +12,16 @@ namespace WixToolset.Mba.Core [ClassInterface(ClassInterfaceType.None)] public abstract class BootstrapperApplication : MarshalByRefObject, IDefaultBootstrapperApplication { - /// - /// Specifies whether this bootstrapper should run asynchronously. The default is true. - /// - protected readonly bool asyncExecution; - /// /// Gets the for interaction with the engine. /// - protected readonly IEngine engine; + protected IEngine engine; - /// - /// Creates a new instance of the class. - /// - protected BootstrapperApplication(IEngine engine) - { - this.engine = engine; - this.asyncExecution = true; - } + /// + public event EventHandler Create; + + /// + public event EventHandler Destroy; /// public event EventHandler Startup; @@ -265,12 +257,6 @@ namespace WixToolset.Mba.Core /// public event EventHandler CachePayloadExtractComplete; - /// - public event EventHandler SetUpdateBegin; - - /// - public event EventHandler SetUpdateComplete; - /// public event EventHandler PlanRestoreRelatedBundle; @@ -283,36 +269,74 @@ namespace WixToolset.Mba.Core /// public event EventHandler CachePackageNonVitalValidationFailure; + /// + /// The default constructor. + /// + /// + /// The engine object will be valid after handling the OnCreate() event. + /// + protected BootstrapperApplication() + { + } + + /// + /// This constructor is no longer used. + /// + [Obsolete("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event.")] + protected BootstrapperApplication(IEngine engine) + { + throw new NotImplementedException("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event."); + } + /// /// Entry point that is called when the bootstrapper application is ready to run. /// protected abstract void Run(); /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnStartup(StartupEventArgs args) + protected virtual void OnCreate(CreateEventArgs args) { - EventHandler handler = this.Startup; + this.engine = args.Engine; + + EventHandler handler = this.Create; if (null != handler) { handler(this, args); } + } - if (this.asyncExecution) + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDestroy(DestroyEventArgs args) + { + EventHandler handler = this.Destroy; + if (null != handler) { - this.engine.Log(LogLevel.Verbose, "Creating BA thread to run asynchronously."); - Thread uiThread = new Thread(this.Run); - uiThread.Name = "UIThread"; - uiThread.SetApartmentState(ApartmentState.STA); - uiThread.Start(); + handler(this, args); } - else + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnStartup(StartupEventArgs args) + { + EventHandler handler = this.Startup; + if (null != handler) { - this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); - this.Run(); + handler(this, args); } + + Thread uiThread = new Thread(this.Run); + uiThread.Name = "UIThread"; + uiThread.SetApartmentState(ApartmentState.STA); + uiThread.Start(); } /// @@ -1315,31 +1339,6 @@ namespace WixToolset.Mba.Core } } - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSetUpdateBegin(SetUpdateBeginEventArgs args) - { - EventHandler handler = this.SetUpdateBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSetUpdateComplete(SetUpdateCompleteEventArgs args) - { - EventHandler handler = this.SetUpdateComplete; - if (null != handler) - { - handler(this, args); - } - } /// /// Called by the engine, raises the event. @@ -1395,7 +1394,7 @@ namespace WixToolset.Mba.Core #region IBootstrapperApplication Members - int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults) { switch (message) { @@ -1404,8 +1403,24 @@ namespace WixToolset.Mba.Core } } - void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr) + { + } + + int IBootstrapperApplication.OnCreate(IBootstrapperEngine engine, ref Command command) { + CreateEventArgs args = new CreateEventArgs(new Engine(engine), command.GetBootstrapperCommand()); + this.OnCreate(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnDestroy(bool reload) + { + DestroyEventArgs args = new DestroyEventArgs(reload); + this.OnDestroy(args); + + return args.HResult; } int IBootstrapperApplication.OnStartup() @@ -2107,22 +2122,6 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnSetUpdateBegin() - { - SetUpdateBeginEventArgs args = new SetUpdateBeginEventArgs(); - this.OnSetUpdateBegin(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnSetUpdateComplete(int hrStatus, string wzPreviousPackageId, string wzNewPackageId) - { - SetUpdateCompleteEventArgs args = new SetUpdateCompleteEventArgs(hrStatus, wzPreviousPackageId, wzNewPackageId); - this.OnSetUpdateComplete(args); - - return args.HResult; - } - int IBootstrapperApplication.OnPlanRestoreRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { PlanRestoreRelatedBundleEventArgs args = new PlanRestoreRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs index 95252cf3..6b465408 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs @@ -5,31 +5,27 @@ namespace WixToolset.Mba.Core using System; /// - /// Identifies the bootstrapper application factory class. + /// This is no longer used. /// - /// - /// This required assembly attribute identifies the bootstrapper application factory class. - /// + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class BootstrapperApplicationFactoryAttribute : Attribute { - private Type bootstrapperApplicationFactoryType; - /// - /// Creates a new instance of the class. + /// This is no longer used. /// - /// The of the BA factory. + /// This is no longer used public BootstrapperApplicationFactoryAttribute(Type bootstrapperApplicationFactoryType) { - this.bootstrapperApplicationFactoryType = bootstrapperApplicationFactoryType; + throw new NotImplementedException(); } /// - /// Gets the type of the bootstrapper application factory class to create. + /// This is no longer used. /// public Type BootstrapperApplicationFactoryType { - get { return this.bootstrapperApplicationFactoryType; } + get { throw new NotImplementedException(); } } } } diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs index ed1dc191..b96a8f95 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -3,10 +3,54 @@ namespace WixToolset.Mba.Core { using System; + using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.InteropServices; + /// + /// Command-line provided to the bootstrapper application. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public struct Command + { + // Strings must be declared as pointers so that Marshaling doesn't free them. + [MarshalAs(UnmanagedType.I4)] internal int cbSize; + [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; + [MarshalAs(UnmanagedType.U4)] private readonly Display display; + private readonly IntPtr wzCommandLine; + [MarshalAs(UnmanagedType.I4)] private readonly int nCmdShow; + [MarshalAs(UnmanagedType.U4)] private readonly ResumeType resume; + private readonly IntPtr hwndSplashScreen; + [MarshalAs(UnmanagedType.I4)] private readonly RelationType relation; + [MarshalAs(UnmanagedType.Bool)] private readonly bool passthrough; + private readonly IntPtr wzLayoutDirectory; + private readonly IntPtr wzBootstrapperWorkingFolder; + private readonly IntPtr wzBootstrapperApplicationDataPath; + + /// + /// Gets the IBootstrapperCommand for this Command. + /// + /// IBootstrapperCommand + public IBootstrapperCommand GetBootstrapperCommand() + { + return new BootstrapperCommand( + this.action, + this.display, + Marshal.PtrToStringUni(this.wzCommandLine), + this.nCmdShow, + this.resume, + this.hwndSplashScreen, + this.relation, + this.passthrough, + Marshal.PtrToStringUni(this.wzLayoutDirectory), + Marshal.PtrToStringUni(this.wzBootstrapperWorkingFolder), + Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); + } + } + /// /// Default implementation of . /// diff --git a/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs index ee751ebf..0039f375 100644 --- a/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs @@ -34,17 +34,17 @@ namespace WixToolset.Mba.Core } /// - public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) + public IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version) { - var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); + var package = PackageInfo.GetRelatedBundleAsPackage(productCode, relationType, perMachine, version); this.Packages.Add(package.Id, package); return package; } /// - public IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e) + public IPackageInfo AddUpdateBundleAsPackage(string packageId) { - var package = PackageInfo.GetUpdateBundleAsPackage(e.NewPackageId); + var package = PackageInfo.GetUpdateBundleAsPackage(packageId); this.Packages.Add(package.Id, package); return package; } diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs index 1120fb1c..df412e8c 100644 --- a/src/api/burn/WixToolset.Mba.Core/Engine.cs +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs @@ -253,9 +253,9 @@ namespace WixToolset.Mba.Core } /// - public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash) + public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId) { - this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash); + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, updatePackageId); } /// diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index 4b7f2245..6506c840 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -197,6 +197,54 @@ namespace WixToolset.Mba.Core public int OverallPercentage { get; private set; } } + /// + /// Event arguments for . + /// + [Serializable] + public class CreateEventArgs : HResultEventArgs + { + /// + /// This class is for events raised by the engine. + /// It is not intended to be instantiated by user code. + /// + public CreateEventArgs(IEngine engine, IBootstrapperCommand command) + { + this.Engine = engine; + this.Command = command; + } + + /// + /// Engine running the application. + /// + public IEngine Engine { get; } + + /// + /// Command line arguments. + /// + public IBootstrapperCommand Command { get; } + } + + /// + /// Event arguments for . + /// + [Serializable] + public class DestroyEventArgs : HResultEventArgs + { + /// + /// This class is for events raised by the engine. + /// It is not intended to be instantiated by user code. + /// + public DestroyEventArgs(bool reload) + { + this.Reload = reload; + } + + /// + /// Bootstrapper application is being reloaded. + /// + public bool Reload { get; } + } + /// /// Event arguments for . /// @@ -2566,49 +2614,6 @@ namespace WixToolset.Mba.Core public string PayloadId { get; private set; } } - /// - /// EventArgs for . - /// - [Serializable] - public class SetUpdateBeginEventArgs : HResultEventArgs - { - /// - /// This class is for events raised by the engine. - /// It is not intended to be instantiated by user code. - /// - public SetUpdateBeginEventArgs() - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class SetUpdateCompleteEventArgs : StatusEventArgs - { - /// - /// This class is for events raised by the engine. - /// It is not intended to be instantiated by user code. - /// - public SetUpdateCompleteEventArgs(int hrStatus, string previousPackageId, string newPackageId) - : base(hrStatus) - { - this.PreviousPackageId = previousPackageId; - this.NewPackageId = newPackageId; - } - - /// - /// Gets the identifier of the update package that was removed. - /// - public string PreviousPackageId { get; private set; } - - /// - /// Gets the identifier of the update package that was added. - /// - public string NewPackageId { 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 36c7fd33..8a255c44 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -21,8 +21,7 @@ namespace WixToolset.Mba.Core int BAProc( int message, IntPtr pvArgs, - IntPtr pvResults, - IntPtr pvContext + IntPtr pvResults ); /// @@ -32,10 +31,23 @@ namespace WixToolset.Mba.Core int message, IntPtr pvArgs, IntPtr pvResults, - ref int phr, - IntPtr pvContext + ref int phr ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCreate(IBootstrapperEngine engine, ref Command command); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDestroy(bool reload); + /// /// See . /// @@ -939,24 +951,6 @@ namespace WixToolset.Mba.Core int hrStatus ); - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSetUpdateBegin(); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSetUpdateComplete( - int hrStatus, - [MarshalAs(UnmanagedType.LPWStr)] string wzPreviousPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzNewPackageId - ); - /// /// See . /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index 2e84de67..393c7e31 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -7,58 +7,16 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; /// - /// Interface used by the native host to dynamically load the BA. + /// This is no longer used. /// - [ComVisible(true)] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] public interface IBootstrapperApplicationFactory { /// - /// Low level method called by the native host. + /// This is no longer used. /// - /// - /// - void Create( - IntPtr pArgs, - IntPtr pResults - ); - } - - [Serializable] - [StructLayout(LayoutKind.Sequential)] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - internal struct Command - { - // Strings must be declared as pointers so that Marshaling doesn't free them. - [MarshalAs(UnmanagedType.I4)] internal int cbSize; - [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; - [MarshalAs(UnmanagedType.U4)] private readonly Display display; - private readonly IntPtr wzCommandLine; - [MarshalAs(UnmanagedType.I4)] private readonly int nCmdShow; - [MarshalAs(UnmanagedType.U4)] private readonly ResumeType resume; - private readonly IntPtr hwndSplashScreen; - [MarshalAs(UnmanagedType.I4)] private readonly RelationType relation; - [MarshalAs(UnmanagedType.Bool)] private readonly bool passthrough; - private readonly IntPtr wzLayoutDirectory; - private readonly IntPtr wzBootstrapperWorkingFolder; - private readonly IntPtr wzBootstrapperApplicationDataPath; - - public IBootstrapperCommand GetBootstrapperCommand() - { - return new BootstrapperCommand( - this.action, - this.display, - Marshal.PtrToStringUni(this.wzCommandLine), - this.nCmdShow, - this.resume, - this.hwndSplashScreen, - this.relation, - this.passthrough, - Marshal.PtrToStringUni(this.wzLayoutDirectory), - Marshal.PtrToStringUni(this.wzBootstrapperWorkingFolder), - Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); - } + /// This is no longer used. + /// This is no longer used. + void Create(IntPtr pArgs, IntPtr pResults); } } diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs index 3f90639f..a175bead 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -108,14 +108,15 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// void SetUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, [MarshalAs(UnmanagedType.U8)] long qwValue, [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, - [MarshalAs(UnmanagedType.LPWStr)] string wzHash + [MarshalAs(UnmanagedType.LPWStr)] string wzHash, + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdatePackageId ); /// @@ -330,12 +331,12 @@ namespace WixToolset.Mba.Core Repair, /// - /// Launch the update registered with and then exit without waiting for it to complete. + /// Launch the update registered with and then exit without waiting for it to complete. /// UpdateReplace, /// - /// Launch the update registered with as an embedded bundle. + /// Launch the update registered with as an embedded bundle. /// UpdateReplaceEmbedded, } diff --git a/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs index 951f511a..3c52fc02 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs @@ -37,15 +37,18 @@ namespace WixToolset.Mba.Core /// /// Adds a related bundle as a package. /// - /// + /// + /// + /// + /// /// The created . - IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); + IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version); /// /// Adds an update bundle as a package. /// - /// + /// Package id added as update bundle. /// The created . - IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e); + IPackageInfo AddUpdateBundleAsPackage(string packageId); } } diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 2fa88bdb..51ea4e4d 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -138,6 +138,16 @@ namespace WixToolset.Mba.Core /// event EventHandler CommitMsiTransactionComplete; + /// + /// Fired when the application is being created. + /// + event EventHandler Create; + + /// + /// Fired when the application is being destroyed. + /// + event EventHandler Destroy; + /// /// Fired when the overall detection phase has begun. /// @@ -393,16 +403,6 @@ namespace WixToolset.Mba.Core /// event EventHandler RollbackMsiTransactionComplete; - /// - /// Fired when the engine has begun to setup the update package. - /// - event EventHandler SetUpdateBegin; - - /// - /// Fired when the engine has completed setting up the update package. - /// - event EventHandler SetUpdateComplete; - /// /// Fired when the engine is shutting down the bootstrapper application. /// diff --git a/src/api/burn/WixToolset.Mba.Core/IEngine.cs b/src/api/burn/WixToolset.Mba.Core/IEngine.cs index 7ffa80d7..dde97a70 100644 --- a/src/api/burn/WixToolset.Mba.Core/IEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IEngine.cs @@ -149,7 +149,8 @@ namespace WixToolset.Mba.Core /// Size of the expected update. /// Type of the hash expected on the update. /// Optional hash expected for the update. - void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash); + /// Optional package id for the update. + void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId); /// /// Sets the URL to the update feed. diff --git a/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs new file mode 100644 index 00000000..74bfbd73 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs @@ -0,0 +1,19 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Mba.Core +{ + /// + /// Managed bootstrapper application entry point. + /// + public static class ManagedBootstrapperApplication + { + /// + /// Run the managed bootstrapper application. + /// + /// Bootstrapper applciation to run. + public static void Run(IBootstrapperApplication application) + { + MbaNative.BootstrapperApplicationRun(application); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/MbaNative.cs b/src/api/burn/WixToolset.Mba.Core/MbaNative.cs index a68a3907..e8e9d576 100644 --- a/src/api/burn/WixToolset.Mba.Core/MbaNative.cs +++ b/src/api/burn/WixToolset.Mba.Core/MbaNative.cs @@ -8,14 +8,10 @@ namespace WixToolset.Mba.Core internal static class MbaNative { [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern IBootstrapperEngine InitializeFromCreateArgs( - IntPtr pArgs, - ref Command pCommand - ); + internal static extern void BootstrapperApplicationDebuggerCheck(); - [DllImport("mbanative.dll", ExactSpelling = true)] - internal static extern void StoreBAInCreateResults( - IntPtr pResults, + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern void BootstrapperApplicationRun( [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA ); } diff --git a/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs index c6373647..b91c52c9 100644 --- a/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs @@ -365,19 +365,19 @@ namespace WixToolset.Mba.Core package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); } - nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", namespaceManager); + nodes = root.Select("/p:BootstrapperApplicationData/p:WixPrereqInformation", namespaceManager); foreach (XPathNavigator node in nodes) { string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); if (id == null) { - throw new Exception("Failed to get package identifier for WixMbaPrereqInformation."); + throw new Exception("Failed to get package identifier for WixPrereqInformation."); } if (!packagesById.TryGetValue(id, out var ipackage)) { - throw new Exception(String.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); + throw new Exception(String.Format("Failed to find package specified in WixPrereqInformation: {0}", id)); } var package = (PackageInfo)ipackage; -- cgit v1.2.3-55-g6feb