From e1e1af1d3940e983bc727bf91a0952840171a279 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 22 Apr 2021 17:30:29 -0500 Subject: Add multiple attached containers error and empty container warning. #6144 --- src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | 7 +++++- .../Bundles/CreateNonUXContainers.cs | 25 +++++++++++++++++----- src/WixToolset.Core.Burn/BurnBackendErrors.cs | 6 ++++++ src/WixToolset.Core.Burn/BurnBackendWarnings.cs | 6 ++++++ .../ContainerFixture.cs | 5 +++-- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index b24481dc..83cc0a67 100644 --- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs @@ -452,7 +452,7 @@ namespace WixToolset.Core.Burn WixBundleContainerSymbol uxContainer; IEnumerable uxPayloads; { - var command = new CreateNonUXContainers(this.BackendHelper, section, bundleApplicationDllSymbol, containers.Values, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel); + var command = new CreateNonUXContainers(this.BackendHelper, this.Messaging, bundleApplicationDllSymbol, containers.Values, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel); command.Execute(); fileTransfers.AddRange(command.FileTransfers); @@ -462,6 +462,11 @@ namespace WixToolset.Core.Burn uxPayloads = command.UXContainerPayloads; } + if (this.Messaging.EncounteredError) + { + return; + } + // Resolve the download URLs now that we have all of the containers and payloads calculated. { var command = new ResolveDownloadUrlsCommand(this.Messaging, this.BackendExtensions, containers.Values, payloadSymbols); diff --git a/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs b/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs index 7b5984c0..f020ed84 100644 --- a/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs +++ b/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs @@ -2,6 +2,7 @@ namespace WixToolset.Core.Burn.Bundles { + using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -14,10 +15,10 @@ namespace WixToolset.Core.Burn.Bundles internal class CreateNonUXContainers { - public CreateNonUXContainers(IBackendHelper backendHelper, IntermediateSection section, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, IEnumerable containerSymbols, Dictionary payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel) + public CreateNonUXContainers(IBackendHelper backendHelper, IMessaging messaging, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, IEnumerable containerSymbols, Dictionary payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel) { this.BackendHelper = backendHelper; - this.Section = section; + this.Messaging = messaging; this.BootstrapperApplicationDllSymbol = bootstrapperApplicationDllSymbol; this.Containers = containerSymbols; this.PayloadSymbols = payloadSymbols; @@ -38,7 +39,7 @@ namespace WixToolset.Core.Burn.Bundles private IBackendHelper BackendHelper { get; } - private IntermediateSection Section { get; } + private IMessaging Messaging { get; } private WixBootstrapperApplicationDllSymbol BootstrapperApplicationDllSymbol { get; } @@ -70,7 +71,7 @@ namespace WixToolset.Core.Burn.Bundles { if (containerId != BurnConstants.BurnDefaultAttachedContainerName) { - // TODO: display warning that we're ignoring container that ended up with no paylods in it. + this.Messaging.Write(BurnBackendWarnings.EmptyContainer(container.SourceLineNumbers, containerId)); } } else if (BurnConstants.BurnUXContainerName == containerId) @@ -113,8 +114,22 @@ namespace WixToolset.Core.Burn.Bundles container.AttachedContainerIndex = attachedContainerIndex; ++attachedContainerIndex; } + } + } - this.CreateContainer(container, containerPayloads); + foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName)) + { + if (container.Type == ContainerType.Attached && attachedContainerIndex > 2 && container.Id.Id != BurnConstants.BurnDefaultAttachedContainerName) + { + this.Messaging.Write(BurnBackendErrors.MultipleAttachedContainersUnsupported(container.SourceLineNumbers, container.Id.Id)); + } + } + + if (!this.Messaging.EncounteredError) + { + foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName)) + { + this.CreateContainer(container, payloadsByContainer[container.Id.Id]); trackedFiles.Add(this.BackendHelper.TrackFile(container.WorkingPath, TrackedFileType.Temporary, container.SourceLineNumbers)); } } diff --git a/src/WixToolset.Core.Burn/BurnBackendErrors.cs b/src/WixToolset.Core.Burn/BurnBackendErrors.cs index 6f9a3706..f23db47d 100644 --- a/src/WixToolset.Core.Burn/BurnBackendErrors.cs +++ b/src/WixToolset.Core.Burn/BurnBackendErrors.cs @@ -36,6 +36,11 @@ namespace WixToolset.Core.Burn return Message(sourceLineNumbers, Ids.ExternalPayloadCollision2, "The location of the symbol related to the previous error."); } + public static Message MultipleAttachedContainersUnsupported(SourceLineNumber sourceLineNumbers, string containerId) + { + return Message(sourceLineNumbers, Ids.MultipleAttachedContainersUnsupported, "Bundles don't currently support having more than one attached container. Either remove all authored attached containers to use the default attached container, or make sure all compressed payloads are included in this Container '{0}'.", containerId); + } + public static Message PackageCachePayloadCollision(SourceLineNumber sourceLineNumbers, string payloadId, string payloadName, string packageId) { return Message(sourceLineNumbers, Ids.PackageCachePayloadCollision, "The Payload '{0}' has a duplicate Name '{1}' in package '{2}'. When caching the package, the file will get overwritten.", payloadId, payloadName, packageId); @@ -61,6 +66,7 @@ namespace WixToolset.Core.Burn ExternalPayloadCollision2 = 8005, PackageCachePayloadCollision = 8006, PackageCachePayloadCollision2 = 8007, + MultipleAttachedContainersUnsupported = 8008, } } } diff --git a/src/WixToolset.Core.Burn/BurnBackendWarnings.cs b/src/WixToolset.Core.Burn/BurnBackendWarnings.cs index cbbc954e..5edbbd67 100644 --- a/src/WixToolset.Core.Burn/BurnBackendWarnings.cs +++ b/src/WixToolset.Core.Burn/BurnBackendWarnings.cs @@ -16,6 +16,11 @@ namespace WixToolset.Core.Burn return Message(sourceLineNumbers, Ids.AttachedContainerPayloadCollision2, "The location of the payload related to the previous error."); } + public static Message EmptyContainer(SourceLineNumber sourceLineNumbers, string containerId) + { + return Message(sourceLineNumbers, Ids.EmptyContainer, "The Container '{0}' is being ignored because it doesn't have any payloads.", containerId); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); @@ -25,6 +30,7 @@ namespace WixToolset.Core.Burn { AttachedContainerPayloadCollision = 8500, AttachedContainerPayloadCollision2 = 8501, + EmptyContainer = 8502, } } } diff --git a/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs index e3dda59d..43fa3f55 100644 --- a/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs @@ -8,6 +8,7 @@ namespace WixToolsetTest.CoreIntegration using System.Linq; using System.Xml; using WixBuildTools.TestSupport; + using WixToolset.Core.Burn; using WixToolset.Core.TestPackage; using WixToolset.Data; using WixToolset.Data.Symbols; @@ -155,7 +156,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "https://github.com/wixtoolset/issues/issues/6144")] + [Fact] public void MultipleAttachedContainersAreNotCurrentlySupported() { var folder = TestData.Get(@"TestData"); @@ -206,7 +207,7 @@ namespace WixToolsetTest.CoreIntegration "-o", bundlePath }); - Assert.InRange(result.ExitCode, 2, Int32.MaxValue); + Assert.Equal((int)BurnBackendErrors.Ids.MultipleAttachedContainersUnsupported, result.ExitCode); } } } -- cgit v1.2.3-55-g6feb