From 28e9c7c14d2a156b55476f6b8e39e13f17aa87b6 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 22 Oct 2022 16:42:25 -0700 Subject: Ensure BA container is only created once in Bundles Fixes 6305 --- src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | 8 +++++++- src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs | 6 ++++++ src/wix/WixToolset.Core/Compiler_Bundle.cs | 11 ++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index 621be346..370364d1 100644 --- a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs @@ -676,10 +676,16 @@ namespace WixToolset.Core.Burn { var symbols = this.Output.Sections.Single().Symbols.OfType().ToList(); - if (1 != symbols.Count) + if (0 == symbols.Count) { throw new WixException(ErrorMessages.MissingBundleInformation(elementName)); } + else if (1 < symbols.Count) + { + // We'll show the first two source line collisions. If there are more than that, the user + // may have to build multiple times to find them all. This should be very rare. + throw new WixException(BurnBackendErrors.MultipleSingletonSymbolsFound(symbols[0].SourceLineNumbers, elementName, symbols[1].SourceLineNumbers)); + } return symbols[0]; } diff --git a/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs b/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs index ee6fc0f8..c0e379ad 100644 --- a/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs +++ b/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs @@ -95,6 +95,11 @@ namespace WixToolset.Core.Burn return Message(sourceLineNumbers, Ids.InvalidBundleManifest, "Unable to read bundle executable '{0}'. Its manifest is invalid. {1}", bundleExecutable, reason); } + public static Message MultipleSingletonSymbolsFound(SourceLineNumber sourceLineNumbers, string friendlyName, SourceLineNumber collisionSourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.MultipleSingletonSymbolsFound, "The Bundle requires a single {0}, but found another at: {1}", friendlyName, collisionSourceLineNumbers.ToString()); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); @@ -116,6 +121,7 @@ namespace WixToolset.Core.Burn FailedToUpdateBundleResources = 8011, InvalidBundleManifest = 8012, BundleMultipleProviders = 8013, + MultipleSingletonSymbolsFound = 8014, } // last available is 8499. 8500 is BurnBackendWarnings. } } diff --git a/src/wix/WixToolset.Core/Compiler_Bundle.cs b/src/wix/WixToolset.Core/Compiler_Bundle.cs index d0911fe9..b9cf8e82 100644 --- a/src/wix/WixToolset.Core/Compiler_Bundle.cs +++ b/src/wix/WixToolset.Core/Compiler_Bundle.cs @@ -439,6 +439,12 @@ namespace WixToolset.Core }); } + this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId) + { + Name = "bundle-ux.cab", + Type = ContainerType.Attached + }); + this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnDefaultAttachedContainerId) { Name = "bundle-attached.cab", @@ -773,11 +779,6 @@ namespace WixToolset.Core if (!this.Core.EncounteredError) { compilerPayload.CreatePayloadSymbol(ComplexReferenceParentType.Container, Compiler.BurnUXContainerId.Id); - this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId) - { - Name = "bundle-ux.cab", - Type = ContainerType.Attached - }); this.Core.AddSymbol(new WixBootstrapperApplicationDllSymbol(sourceLineNumbers, compilerPayload.Id) { -- cgit v1.2.3-55-g6feb