@joebigelow / wix / commits / 28e9c7c1

Ensure BA container is only created once in Bundles

Fixes 6305

Rob Mensching committed Oct 22, 2022 at 16:42 UTC 28e9c7c14d2a156b55476f6b8e39e13f17aa87b6
3 files changed +19 -6
src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+7 -1
@@ -676,10 +676,16 @@ namespace WixToolset.Core.Burn
676 {
677 var symbols = this.Output.Sections.Single().Symbols.OfType<T>().ToList();
678
679 - if (1 != symbols.Count)
679 + if (0 == symbols.Count)
680 {
681 throw new WixException(ErrorMessages.MissingBundleInformation(elementName));
682 }
683 + else if (1 < symbols.Count)
684 + {
685 + // We'll show the first two source line collisions. If there are more than that, the user
686 + // may have to build multiple times to find them all. This should be very rare.
687 + throw new WixException(BurnBackendErrors.MultipleSingletonSymbolsFound(symbols[0].SourceLineNumbers, elementName, symbols[1].SourceLineNumbers));
688 + }
689
690 return symbols[0];
691 }
src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs
+6
@@ -95,6 +95,11 @@ namespace WixToolset.Core.Burn
95 return Message(sourceLineNumbers, Ids.InvalidBundleManifest, "Unable to read bundle executable '{0}'. Its manifest is invalid. {1}", bundleExecutable, reason);
96 }
97
98 + public static Message MultipleSingletonSymbolsFound(SourceLineNumber sourceLineNumbers, string friendlyName, SourceLineNumber collisionSourceLineNumbers)
99 + {
100 + return Message(sourceLineNumbers, Ids.MultipleSingletonSymbolsFound, "The Bundle requires a single {0}, but found another at: {1}", friendlyName, collisionSourceLineNumbers.ToString());
101 + }
102 +
103 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
104 {
105 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
@@ -116,6 +121,7 @@ namespace WixToolset.Core.Burn
121 FailedToUpdateBundleResources = 8011,
122 InvalidBundleManifest = 8012,
123 BundleMultipleProviders = 8013,
124 + MultipleSingletonSymbolsFound = 8014,
125 } // last available is 8499. 8500 is BurnBackendWarnings.
126 }
127 }
src/wix/WixToolset.Core/Compiler_Bundle.cs
+6 -5
@@ -439,6 +439,12 @@ namespace WixToolset.Core
439 });
440 }
441
442 + this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId)
443 + {
444 + Name = "bundle-ux.cab",
445 + Type = ContainerType.Attached
446 + });
447 +
448 this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnDefaultAttachedContainerId)
449 {
450 Name = "bundle-attached.cab",
@@ -773,11 +779,6 @@ namespace WixToolset.Core
779 if (!this.Core.EncounteredError)
780 {
781 compilerPayload.CreatePayloadSymbol(ComplexReferenceParentType.Container, Compiler.BurnUXContainerId.Id);
776 - this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId)
777 - {
778 - Name = "bundle-ux.cab",
779 - Type = ContainerType.Attached
780 - });
782
783 this.Core.AddSymbol(new WixBootstrapperApplicationDllSymbol(sourceLineNumbers, compilerPayload.Id)
784 {