From ef68dbf1523800dbf49fa8d10e220d100442780e Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 25 Aug 2022 21:54:29 -0400 Subject: Error on non-embedded explicit container payloads. Fixes https://github.com/wixtoolset/issues/issues/6845. --- .../WixToolset.Core.Burn/Bind/BindBundleCommand.cs | 14 ----------- src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs | 6 ----- .../Link/FlattenAndProcessBundleTablesCommand.cs | 29 +++++++++++++++++++--- src/wix/WixToolset.Core/LinkerErrors.cs | 12 +++++++++ src/wix/WixToolset.Core/LinkerWarnings.cs | 6 ----- .../PayloadFixture.cs | 6 ----- .../Payload/DownloadUrlPlaceholdersBundle.wxs | 2 +- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index cd0590d0..d001bf50 100644 --- a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs @@ -290,20 +290,6 @@ namespace WixToolset.Core.Burn { foreach (var payload in payloadSymbols.Values.Where(p => BurnConstants.BurnUXContainerName == p.ContainerRef)) { - // In theory, UX payloads could be embedded in the UX CAB, external to the bundle EXE, or even - // downloaded. The current engine requires the UX to be fully present before any downloading starts, - // so that rules out downloading. Also, the burn engine does not currently copy external UX payloads - // into the temporary UX directory correctly, so we don't allow external either. - if (payload.SourceFile is null) - { - this.Messaging.Write(BurnBackendErrors.BAContainerCannotContainRemotePayload(payload.SourceLineNumbers, payload.Name)); - } - else if (PackagingType.Embedded != payload.Packaging) - { - this.Messaging.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(payload.SourceLineNumbers, payload.SourceFile.Path)); - payload.Packaging = PackagingType.Embedded; - } - payload.EmbeddedId = String.Format(CultureInfo.InvariantCulture, BurnCommon.BurnUXContainerEmbeddedIdFormat, uxPayloadIndex); ++uxPayloadIndex; } diff --git a/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs b/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs index cc3a998f..04290667 100644 --- a/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs +++ b/src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs @@ -95,11 +95,6 @@ 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 BAContainerCannotContainRemotePayload(SourceLineNumber sourceLineNumbers, string payloadName) - { - return Message(sourceLineNumbers, Ids.BAContainerCannotContainRemotePayload, "Bootstrapper application and bundle extension payloads must be embedded in the bundle. The payload '{0}' is remote thus cannot be found for embedding. Provide a full path to the payload via the Payload/@SourceFile attribute.", payloadName); - } - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); @@ -121,7 +116,6 @@ namespace WixToolset.Core.Burn FailedToAddIconOrSplashScreenToBundle = 8011, InvalidBundleManifest = 8012, BundleMultipleProviders = 8013, - BAContainerCannotContainRemotePayload = 8014, } // last available is 8499. 8500 is BurnBackendWarnings. } } diff --git a/src/wix/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs b/src/wix/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs index 6c1c0cf3..48b2286d 100644 --- a/src/wix/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs +++ b/src/wix/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs @@ -171,11 +171,32 @@ namespace WixToolset.Core.Link { if (payloadSymbol.Compressed == false) { - this.Messaging.Write(LinkerWarnings.UncompressedPayloadInContainer(payloadSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId)); + if (containerId == BurnConstants.BurnUXContainerName) + { + // In theory, UX payloads could be embedded in the UX CAB, external to the bundle EXE, or even + // downloaded. The current engine requires the UX to be fully present before any downloading starts, + // so that rules out downloading. Also, the burn engine does not currently copy external UX payloads + // into the temporary UX directory correctly, so we don't allow external either. + if (payloadSymbol.SourceFile is null) + { + this.Messaging.Write(LinkerErrors.BAContainerCannotContainRemotePayload(payloadSymbol.SourceLineNumbers, payloadSymbol.Name)); + } + else if (PackagingType.Embedded != payloadSymbol.Packaging) + { + this.Messaging.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(payloadSymbol.SourceLineNumbers, payloadSymbol.SourceFile.Path)); + payloadSymbol.Packaging = PackagingType.Embedded; + } + } + else + { + this.Messaging.Write(LinkerErrors.UncompressedPayloadInContainer(payloadSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId)); + } + } + else + { + payloadSymbol.Compressed = true; + payloadSymbol.ContainerRef = containerId; } - - payloadSymbol.Compressed = true; - payloadSymbol.ContainerRef = containerId; } else { diff --git a/src/wix/WixToolset.Core/LinkerErrors.cs b/src/wix/WixToolset.Core/LinkerErrors.cs index 7ce8c00e..1d9a5a07 100644 --- a/src/wix/WixToolset.Core/LinkerErrors.cs +++ b/src/wix/WixToolset.Core/LinkerErrors.cs @@ -31,6 +31,16 @@ namespace WixToolset.Core return Message(sourceLineNumbers, Ids.UnscheduledRollbackBoundary, "Found orphaned RollbackBoundary '{0}'. Make sure to reference it from the Chain or move it into its own Fragment so it only gets linked in when actually used.", rollbackBoundaryId); } + public static Message BAContainerCannotContainRemotePayload(SourceLineNumber sourceLineNumbers, string payloadName) + { + return Message(sourceLineNumbers, Ids.BAContainerCannotContainRemotePayload, "Bootstrapper application and bundle extension payloads must be embedded in the bundle. The payload '{0}' is remote thus cannot be found for embedding. Provide a full path to the payload via the Payload/@SourceFile attribute.", payloadName); + } + + public static Message UncompressedPayloadInContainer(SourceLineNumber sourceLineNumbers, string payloadId, string containerId) + { + return Message(sourceLineNumbers, Ids.UncompressedPayloadInContainer, "The payload '{0}' is uncompressed and cannot be added to container '{1}'. Remove its Compressed attribute and provide a @SourceFile value to allow it to be added to a container.", payloadId, containerId); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); @@ -43,6 +53,8 @@ namespace WixToolset.Core PayloadSharedWithBA = 7002, UnscheduledChainPackage = 7003, UnscheduledRollbackBoundary = 7004, + UncompressedPayloadInContainer = 7005, + BAContainerCannotContainRemotePayload = 7006, } // last available is 7099. 7100 is WindowsInstallerBackendWarnings. } } diff --git a/src/wix/WixToolset.Core/LinkerWarnings.cs b/src/wix/WixToolset.Core/LinkerWarnings.cs index 968fa4ea..0eca090e 100644 --- a/src/wix/WixToolset.Core/LinkerWarnings.cs +++ b/src/wix/WixToolset.Core/LinkerWarnings.cs @@ -16,11 +16,6 @@ namespace WixToolset.Core return Message(sourceLineNumbers, Ids.PayloadInMultipleContainers, "The Payload '{0}' can't be added to Container '{1}' because it was already added to Container '{2}'.", payloadId, containerId1, containerId2); } - public static Message UncompressedPayloadInContainer(SourceLineNumber sourceLineNumbers, string payloadId, string containerId) - { - return Message(sourceLineNumbers, Ids.UncompressedPayloadInContainer, "The Payload '{0}' is being added to Container '{1}', overriding its Compressed value of 'no'.", payloadId, containerId); - } - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); @@ -30,7 +25,6 @@ namespace WixToolset.Core { LayoutPayloadInContainer = 6900, PayloadInMultipleContainers = 6901, - UncompressedPayloadInContainer = 6902, } // last available is 6999. 7000 is LinkerErrors. } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs index 58357ca9..cd27ff14 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs @@ -169,11 +169,6 @@ namespace WixToolsetTest.CoreIntegration result.AssertSuccess(); - WixAssert.CompareLineByLine(new[] - { - "The Payload 'burn.exe' is being added to Container 'PackagesContainer', overriding its Compressed value of 'no'.", - }, result.Messages.Select(m => m.ToString()).ToArray()); - Assert.True(File.Exists(bundlePath)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); @@ -277,7 +272,6 @@ namespace WixToolsetTest.CoreIntegration WixAssert.CompareLineByLine(new[] { - "The Payload 'RemotePayload' is being added to Container 'WixUXContainer', overriding its Compressed value of 'no'.", "Bootstrapper application and bundle extension payloads must be embedded in the bundle. The payload 'someremotefile.txt' is remote thus cannot be found for embedding. Provide a full path to the payload via the Payload/@SourceFile attribute." }, result.Messages.Select(m => m.ToString()).ToArray()); } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Payload/DownloadUrlPlaceholdersBundle.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Payload/DownloadUrlPlaceholdersBundle.wxs index f077c418..f964f526 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Payload/DownloadUrlPlaceholdersBundle.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Payload/DownloadUrlPlaceholdersBundle.wxs @@ -14,7 +14,7 @@ - + -- cgit v1.2.3-55-g6feb