@joebigelow / wix-1 / commits / c3fa0b4c

Enforce that Update and RemoteBundle can only be specified once.

Also, RemoteBundle is required if BundlePackagePayload is remote.

Sean Hall committed Apr 25, 2022 at 17:53 UTC c3fa0b4cfe33109244d6f4e1c12d79abb7b28864
1 file changed +21
src/wix/WixToolset.Core/Compiler_Bundle.cs
+21
@@ -309,6 +309,7 @@ namespace WixToolset.Core
309
310 var chainSeen = false;
311 var logSeen = false;
312 + var updateSeen = false;
313
314 foreach (var child in node.Elements())
315 {
@@ -386,7 +387,13 @@ namespace WixToolset.Core
387 this.ParseBundleTagElement(child);
388 break;
389 case "Update":
390 + if (updateSeen)
391 + {
392 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
393 + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "Update"));
394 + }
395 this.ParseUpdateElement(child);
396 + updateSeen = true;
397 break;
398 case "Variable":
399 this.ParseVariableElement(child);
@@ -2670,6 +2677,8 @@ namespace WixToolset.Core
2677 this.Core.ParseExtensionAttribute(node, extensionAttribute, context);
2678 }
2679
2680 + var remoteBundleSeen = false;
2681 +
2682 foreach (var child in node.Elements())
2683 {
2684 if (CompilerCore.WixNamespace == child.Name.Namespace)
@@ -2682,7 +2691,13 @@ namespace WixToolset.Core
2691
2692 if (allowed)
2693 {
2694 + if (remoteBundleSeen)
2695 + {
2696 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
2697 + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "RemoteBundle"));
2698 + }
2699 this.ParseRemoteBundleElement(child, compilerPayload.Id.Id);
2700 + remoteBundleSeen = true;
2701 }
2702
2703 break;
@@ -2702,6 +2717,12 @@ namespace WixToolset.Core
2717 }
2718 }
2719
2720 + var isLocal = !String.IsNullOrEmpty(compilerPayload.SourceFile);
2721 + if (packageType == WixBundlePackageType.Bundle && !isLocal && !remoteBundleSeen)
2722 + {
2723 + this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName, "RemoteBundle"));
2724 + }
2725 +
2726 return compilerPayload;
2727 }
2728