@joebigelow / wix / commits / ef68dbf1

Error on non-embedded explicit container payloads.

Fixes https://github.com/wixtoolset/issues/issues/6845.

Bob Arnson committed Aug 25, 2022 at 21:54 UTC ef68dbf1523800dbf49fa8d10e220d100442780e
7 files changed +38 -37
src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
-14
@@ -290,20 +290,6 @@ namespace WixToolset.Core.Burn
290 {
291 foreach (var payload in payloadSymbols.Values.Where(p => BurnConstants.BurnUXContainerName == p.ContainerRef))
292 {
293 - // In theory, UX payloads could be embedded in the UX CAB, external to the bundle EXE, or even
294 - // downloaded. The current engine requires the UX to be fully present before any downloading starts,
295 - // so that rules out downloading. Also, the burn engine does not currently copy external UX payloads
296 - // into the temporary UX directory correctly, so we don't allow external either.
297 - if (payload.SourceFile is null)
298 - {
299 - this.Messaging.Write(BurnBackendErrors.BAContainerCannotContainRemotePayload(payload.SourceLineNumbers, payload.Name));
300 - }
301 - else if (PackagingType.Embedded != payload.Packaging)
302 - {
303 - this.Messaging.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(payload.SourceLineNumbers, payload.SourceFile.Path));
304 - payload.Packaging = PackagingType.Embedded;
305 - }
306 -
293 payload.EmbeddedId = String.Format(CultureInfo.InvariantCulture, BurnCommon.BurnUXContainerEmbeddedIdFormat, uxPayloadIndex);
294 ++uxPayloadIndex;
295 }
src/wix/WixToolset.Core.Burn/BurnBackendErrors.cs
-6
@@ -95,11 +95,6 @@ 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 BAContainerCannotContainRemotePayload(SourceLineNumber sourceLineNumbers, string payloadName)
99 - {
100 - 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);
101 - }
102 -
98 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
99 {
100 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
@@ -121,7 +116,6 @@ namespace WixToolset.Core.Burn
116 FailedToAddIconOrSplashScreenToBundle = 8011,
117 InvalidBundleManifest = 8012,
118 BundleMultipleProviders = 8013,
124 - BAContainerCannotContainRemotePayload = 8014,
119 } // last available is 8499. 8500 is BurnBackendWarnings.
120 }
121 }
src/wix/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs
+25 -4
@@ -171,11 +171,32 @@ namespace WixToolset.Core.Link
171 {
172 if (payloadSymbol.Compressed == false)
173 {
174 - this.Messaging.Write(LinkerWarnings.UncompressedPayloadInContainer(payloadSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId));
174 + if (containerId == BurnConstants.BurnUXContainerName)
175 + {
176 + // In theory, UX payloads could be embedded in the UX CAB, external to the bundle EXE, or even
177 + // downloaded. The current engine requires the UX to be fully present before any downloading starts,
178 + // so that rules out downloading. Also, the burn engine does not currently copy external UX payloads
179 + // into the temporary UX directory correctly, so we don't allow external either.
180 + if (payloadSymbol.SourceFile is null)
181 + {
182 + this.Messaging.Write(LinkerErrors.BAContainerCannotContainRemotePayload(payloadSymbol.SourceLineNumbers, payloadSymbol.Name));
183 + }
184 + else if (PackagingType.Embedded != payloadSymbol.Packaging)
185 + {
186 + this.Messaging.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(payloadSymbol.SourceLineNumbers, payloadSymbol.SourceFile.Path));
187 + payloadSymbol.Packaging = PackagingType.Embedded;
188 + }
189 + }
190 + else
191 + {
192 + this.Messaging.Write(LinkerErrors.UncompressedPayloadInContainer(payloadSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId));
193 + }
194 + }
195 + else
196 + {
197 + payloadSymbol.Compressed = true;
198 + payloadSymbol.ContainerRef = containerId;
199 }
176 -
177 - payloadSymbol.Compressed = true;
178 - payloadSymbol.ContainerRef = containerId;
200 }
201 else
202 {
src/wix/WixToolset.Core/LinkerErrors.cs
+12
@@ -31,6 +31,16 @@ namespace WixToolset.Core
31 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);
32 }
33
34 + public static Message BAContainerCannotContainRemotePayload(SourceLineNumber sourceLineNumbers, string payloadName)
35 + {
36 + 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);
37 + }
38 +
39 + public static Message UncompressedPayloadInContainer(SourceLineNumber sourceLineNumbers, string payloadId, string containerId)
40 + {
41 + 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);
42 + }
43 +
44 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
45 {
46 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
@@ -43,6 +53,8 @@ namespace WixToolset.Core
53 PayloadSharedWithBA = 7002,
54 UnscheduledChainPackage = 7003,
55 UnscheduledRollbackBoundary = 7004,
56 + UncompressedPayloadInContainer = 7005,
57 + BAContainerCannotContainRemotePayload = 7006,
58 } // last available is 7099. 7100 is WindowsInstallerBackendWarnings.
59 }
60 }
src/wix/WixToolset.Core/LinkerWarnings.cs
-6
@@ -16,11 +16,6 @@ namespace WixToolset.Core
16 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);
17 }
18
19 - public static Message UncompressedPayloadInContainer(SourceLineNumber sourceLineNumbers, string payloadId, string containerId)
20 - {
21 - return Message(sourceLineNumbers, Ids.UncompressedPayloadInContainer, "The Payload '{0}' is being added to Container '{1}', overriding its Compressed value of 'no'.", payloadId, containerId);
22 - }
23 -
19 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
20 {
21 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
@@ -30,7 +25,6 @@ namespace WixToolset.Core
25 {
26 LayoutPayloadInContainer = 6900,
27 PayloadInMultipleContainers = 6901,
33 - UncompressedPayloadInContainer = 6902,
28 } // last available is 6999. 7000 is LinkerErrors.
29 }
30 }
src/wix/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs
-6
@@ -169,11 +169,6 @@ namespace WixToolsetTest.CoreIntegration
169
170 result.AssertSuccess();
171
172 - WixAssert.CompareLineByLine(new[]
173 - {
174 - "The Payload 'burn.exe' is being added to Container 'PackagesContainer', overriding its Compressed value of 'no'.",
175 - }, result.Messages.Select(m => m.ToString()).ToArray());
176 -
172 Assert.True(File.Exists(bundlePath));
173
174 var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
@@ -277,7 +272,6 @@ namespace WixToolsetTest.CoreIntegration
272
273 WixAssert.CompareLineByLine(new[]
274 {
280 - "The Payload 'RemotePayload' is being added to Container 'WixUXContainer', overriding its Compressed value of 'no'.",
275 "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."
276 }, result.Messages.Select(m => m.ToString()).ToArray());
277 }
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Payload/DownloadUrlPlaceholdersBundle.wxs
+1 -1
@@ -14,7 +14,7 @@
14 </Bundle>
15 <Fragment>
16 <PackageGroup Id="ContainerPackages">
17 - <ExePackage SourceFile="burn.exe" DetectCondition="none" UninstallArguments="-u" Compressed="no" />
17 + <ExePackage SourceFile="burn.exe" DetectCondition="none" UninstallArguments="-u" />
18 </PackageGroup>
19 </Fragment>
20 <Fragment>