From edccb203c421d2bd820062024088c6698424d9ee Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 4 Feb 2026 20:47:04 -0500 Subject: Support dual-purpose packages in Burn. Fixes https://github.com/wixtoolset/issues/issues/8958 --- .../BootstrapperCommand.cs | 7 ++++++ .../Engine.cs | 20 ++++++++-------- .../IBootstrapperCommand.cs | 5 ++++ .../IBootstrapperEngine.cs | 27 ++++++++++++++++++++-- .../IEngine.cs | 3 ++- src/api/burn/balutil/BalBootstrapperEngine.cpp | 13 +++++++---- .../burn/balutil/inc/BootstrapperApplicationBase.h | 14 +++++++---- src/api/burn/balutil/inc/IBootstrapperEngine.h | 3 ++- src/api/burn/inc/BootstrapperApplicationTypes.h | 11 +++++++++ src/api/burn/inc/BootstrapperEngineTypes.h | 10 +++++++- 10 files changed, 89 insertions(+), 24 deletions(-) (limited to 'src/api/burn') diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperCommand.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperCommand.cs index 612e8ce9..795a40d4 100644 --- a/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperCommand.cs +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/BootstrapperCommand.cs @@ -20,6 +20,7 @@ namespace WixToolset.BootstrapperApplicationApi [MarshalAs(UnmanagedType.I4)] internal int cbSize; [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; [MarshalAs(UnmanagedType.U4)] private readonly Display display; + [MarshalAs(UnmanagedType.U4)] private readonly BundleScope scope; private readonly IntPtr wzCommandLine; [MarshalAs(UnmanagedType.I4)] private readonly int nCmdShow; [MarshalAs(UnmanagedType.U4)] private readonly ResumeType resume; @@ -39,6 +40,7 @@ namespace WixToolset.BootstrapperApplicationApi return new BootstrapperCommand( this.action, this.display, + this.scope, Marshal.PtrToStringUni(this.wzCommandLine), this.nCmdShow, this.resume, @@ -62,6 +64,7 @@ namespace WixToolset.BootstrapperApplicationApi public BootstrapperCommand( LaunchAction action, Display display, + BundleScope scope, string commandLine, int cmdShow, ResumeType resume, @@ -74,6 +77,7 @@ namespace WixToolset.BootstrapperApplicationApi { this.Action = action; this.Display = display; + this.Scope = scope; this.CommandLine = commandLine; this.CmdShow = cmdShow; this.Resume = resume; @@ -91,6 +95,9 @@ namespace WixToolset.BootstrapperApplicationApi /// public Display Display { get; } + /// + public BundleScope Scope { get; } + /// public string CommandLine { get; } diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/Engine.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/Engine.cs index 25413790..82978b7d 100644 --- a/src/api/burn/WixToolset.BootstrapperApplicationApi/Engine.cs +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/Engine.cs @@ -12,7 +12,7 @@ namespace WixToolset.BootstrapperApplicationApi /// public sealed class Engine : IEngine { - private IBootstrapperEngine engine; + private readonly IBootstrapperEngine engine; internal Engine(IBootstrapperEngine engine) { @@ -24,8 +24,7 @@ namespace WixToolset.BootstrapperApplicationApi { get { - int count; - this.engine.GetPackageCount(out count); + this.engine.GetPackageCount(out var count); return count; } @@ -110,8 +109,7 @@ namespace WixToolset.BootstrapperApplicationApi /// public bool EvaluateCondition(string condition) { - bool value; - this.engine.EvaluateCondition(condition, out value); + this.engine.EvaluateCondition(condition, out var value); return value; } @@ -247,9 +245,9 @@ namespace WixToolset.BootstrapperApplicationApi } /// - public void Plan(LaunchAction action) + public void Plan(LaunchAction action, BundleScope plannedScope) { - this.engine.Plan(action); + this.engine.Plan(action, plannedScope); } /// @@ -327,16 +325,16 @@ namespace WixToolset.BootstrapperApplicationApi /// public int SendEmbeddedError(int errorCode, string message, int uiHint) { - int result = 0; - this.engine.SendEmbeddedError(errorCode, message, uiHint, out result); + this.engine.SendEmbeddedError(errorCode, message, uiHint, out var result); + return result; } /// public int SendEmbeddedProgress(int progressPercentage, int overallPercentage) { - int result = 0; - this.engine.SendEmbeddedProgress(progressPercentage, overallPercentage, out result); + this.engine.SendEmbeddedProgress(progressPercentage, overallPercentage, out var result); + return result; } diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperCommand.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperCommand.cs index a1f8bfe0..7a5a4cfd 100644 --- a/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperCommand.cs +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperCommand.cs @@ -19,6 +19,11 @@ namespace WixToolset.BootstrapperApplicationApi /// Display Display { get; } + /// + /// Gets the bundle scope if set at the command line. + /// + BundleScope Scope { get; } + /// /// Gets the command line arguments. /// diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperEngine.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperEngine.cs index 13702757..9df57cd3 100644 --- a/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperEngine.cs +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperEngine.cs @@ -178,10 +178,11 @@ namespace WixToolset.BootstrapperApplicationApi ); /// - /// See . + /// See . /// void Plan( - [MarshalAs(UnmanagedType.U4)] LaunchAction action + [MarshalAs(UnmanagedType.U4)] LaunchAction action, + [MarshalAs(UnmanagedType.U4)] BundleScope plannedScope ); /// @@ -343,6 +344,28 @@ namespace WixToolset.BootstrapperApplicationApi UpdateReplaceEmbedded, } + /// + /// The scope of the bundle when the chain contains per-user-or-machine or per-machone-or-user packages. + /// + public enum BundleScope + { + /// + /// Let Burn choose the scope. Per-user-or-machine packages will be + /// planned as per-machine packages. + /// + Default, + + /// + /// Set per-machine scope for per-user-or-machine packages. + /// + PerMachine, + + /// + /// Set per-user scope for per-user-or-machine packages. + /// + PerUser, + } + /// /// The message log level. /// diff --git a/src/api/burn/WixToolset.BootstrapperApplicationApi/IEngine.cs b/src/api/burn/WixToolset.BootstrapperApplicationApi/IEngine.cs index 03ceed06..a763d741 100644 --- a/src/api/burn/WixToolset.BootstrapperApplicationApi/IEngine.cs +++ b/src/api/burn/WixToolset.BootstrapperApplicationApi/IEngine.cs @@ -139,7 +139,8 @@ namespace WixToolset.BootstrapperApplicationApi /// Determine the installation sequencing and costing. /// /// The action to perform when planning. - void Plan(LaunchAction action); + /// The bundle scope for per-user-or-machine packages. + void Plan(LaunchAction action, BundleScope plannedScope); /// /// Set the update information for a bundle. diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index 61e7e31b..14aa5c25 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp @@ -1188,7 +1188,8 @@ public: // IBootstrapperEngine } virtual STDMETHODIMP Plan( - __in BOOTSTRAPPER_ACTION action + __in BOOTSTRAPPER_ACTION action, + __in BOOTSTRAPPER_SCOPE plannedScope ) { HRESULT hr = S_OK; @@ -1199,17 +1200,21 @@ public: // IBootstrapperEngine PIPE_RPC_RESULT rpc = { }; // Init send structs. - args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + args.dwApiVersion = WIX_7_BOOTSTRAPPER_APPLICATION_API_VERSION; args.action = action; + args.plannedScope = plannedScope; - results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + results.dwApiVersion = WIX_7_BOOTSTRAPPER_APPLICATION_API_VERSION; // Send args. hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); ExitOnFailure(hr, "Failed to write API version of Plan args."); hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.action)); - ExitOnFailure(hr, "Failed to write parent window of Plan args."); + ExitOnFailure(hr, "Failed to write action of Plan args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.plannedScope)); + ExitOnFailure(hr, "Failed to write planned scope of Plan args."); // Send results. hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); diff --git a/src/api/burn/balutil/inc/BootstrapperApplicationBase.h b/src/api/burn/balutil/inc/BootstrapperApplicationBase.h index 80bfd361..41c151d9 100644 --- a/src/api/burn/balutil/inc/BootstrapperApplicationBase.h +++ b/src/api/burn/balutil/inc/BootstrapperApplicationBase.h @@ -16,7 +16,7 @@ class CBootstrapperApplicationBase : public IBootstrapperApplication public: // IUnknown virtual STDMETHODIMP QueryInterface( __in REFIID riid, - __out LPVOID *ppvObject + __out LPVOID* ppvObject ) { if (!ppvObject) @@ -478,12 +478,14 @@ public: // IBootstrapperApplication __in DWORD dwCode, __in_z LPCWSTR wzError, __in DWORD dwUIHint, - __in DWORD /*cData*/, + __in DWORD cData, __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, __in int /*nRecommendation*/, __inout int* pResult ) { + UNREFERENCED_PARAMETER(cData); + BalRetryErrorOccurred(wzPackageId, dwCode); if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_commandDisplay) @@ -781,12 +783,14 @@ public: // IBootstrapperApplication __in INSTALLMESSAGE /*messageType*/, __in DWORD /*dwUIHint*/, __in_z LPCWSTR /*wzMessage*/, - __in DWORD /*cData*/, + __in DWORD cData, __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, __in int /*nRecommendation*/, __inout int* pResult ) { + UNREFERENCED_PARAMETER(cData); + if (CheckCanceled()) { *pResult = IDCANCEL; @@ -797,13 +801,15 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnExecuteFilesInUse( __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*cFiles*/, + __in DWORD cFiles, __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, __in int /*nRecommendation*/, __in BOOTSTRAPPER_FILES_IN_USE_TYPE /*source*/, __inout int* pResult ) { + UNREFERENCED_PARAMETER(cFiles); + if (CheckCanceled()) { *pResult = IDCANCEL; diff --git a/src/api/burn/balutil/inc/IBootstrapperEngine.h b/src/api/burn/balutil/inc/IBootstrapperEngine.h index 57fc9be9..ad6e6042 100644 --- a/src/api/burn/balutil/inc/IBootstrapperEngine.h +++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h @@ -108,7 +108,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 ) = 0; STDMETHOD(Plan)( - __in BOOTSTRAPPER_ACTION action + __in BOOTSTRAPPER_ACTION action, + __in BOOTSTRAPPER_SCOPE plannedScope ) = 0; STDMETHOD(Elevate)( diff --git a/src/api/burn/inc/BootstrapperApplicationTypes.h b/src/api/burn/inc/BootstrapperApplicationTypes.h index 2ece1b7b..b430e04a 100644 --- a/src/api/burn/inc/BootstrapperApplicationTypes.h +++ b/src/api/burn/inc/BootstrapperApplicationTypes.h @@ -10,6 +10,7 @@ extern "C" { const LPCWSTR BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_API_VERSION = L"burn.ba.apiver"; const LPCWSTR BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_PIPE_NAME = L"burn.ba.pipe"; const DWORD WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION = 5; +const DWORD WIX_7_BOOTSTRAPPER_APPLICATION_API_VERSION = 7; enum BOOTSTRAPPER_DISPLAY { @@ -27,6 +28,15 @@ enum BOOTSTRAPPER_REGISTRATION_TYPE BOOTSTRAPPER_REGISTRATION_TYPE_FULL, }; +enum BOOTSTRAPPER_PACKAGE_SCOPE +{ + BOOTSTRAPPER_PACKAGE_SCOPE_INVALID, + BOOTSTRAPPER_PACKAGE_SCOPE_PER_MACHINE, + BOOTSTRAPPER_PACKAGE_SCOPE_PER_MACHINE_OR_PER_USER, + BOOTSTRAPPER_PACKAGE_SCOPE_PER_USER_OR_PER_MACHINE, + BOOTSTRAPPER_PACKAGE_SCOPE_PER_USER, +}; + enum BOOTSTRAPPER_RESUME_TYPE { BOOTSTRAPPER_RESUME_TYPE_NONE, @@ -353,6 +363,7 @@ struct BOOTSTRAPPER_COMMAND DWORD cbSize; BOOTSTRAPPER_ACTION action; BOOTSTRAPPER_DISPLAY display; + BOOTSTRAPPER_SCOPE commandLineScope; LPWSTR wzCommandLine; INT32 nCmdShow; diff --git a/src/api/burn/inc/BootstrapperEngineTypes.h b/src/api/burn/inc/BootstrapperEngineTypes.h index f89238c0..6dced349 100644 --- a/src/api/burn/inc/BootstrapperEngineTypes.h +++ b/src/api/burn/inc/BootstrapperEngineTypes.h @@ -30,6 +30,13 @@ enum BOOTSTRAPPER_ACTION BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED, }; +enum BOOTSTRAPPER_SCOPE +{ + BOOTSTRAPPER_SCOPE_DEFAULT, + BOOTSTRAPPER_SCOPE_PER_MACHINE, + BOOTSTRAPPER_SCOPE_PER_USER, +}; + enum BOOTSTRAPPER_ACTION_STATE { BOOTSTRAPPER_ACTION_STATE_NONE, @@ -183,7 +190,7 @@ typedef struct _BAENGINE_ESCAPESTRING_RESULTS { DWORD dwApiVersion; LPWSTR wzOut; - // Should be initialized to the size of wzOut. + // Should be initialized to the count of wzOut. DWORD cchOut; } BAENGINE_ESCAPESTRING_RESULTS; @@ -306,6 +313,7 @@ typedef struct _BAENGINE_PLAN_ARGS { DWORD dwApiVersion; BOOTSTRAPPER_ACTION action; + BOOTSTRAPPER_SCOPE plannedScope; } BAENGINE_PLAN_ARGS; typedef struct _BAENGINE_PLAN_RESULTS -- cgit v1.2.3-55-g6feb