diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-12-08 23:03:30 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-12-09 13:33:18 -0600 |
| commit | 70e370b4494a87cbbe234130882cad4a1021f82a (patch) | |
| tree | 62966467e371f884bd987d539f840242f9245c61 /src/wixext/BalCompiler.cs | |
| parent | c52a40fc649b0aebb673cced64a2773aa2425e2d (diff) | |
| download | wix-70e370b4494a87cbbe234130882cad4a1021f82a.tar.gz wix-70e370b4494a87cbbe234130882cad4a1021f82a.tar.bz2 wix-70e370b4494a87cbbe234130882cad4a1021f82a.zip | |
Require the custom BA elements to reference built-in BAs.
Diffstat (limited to 'src/wixext/BalCompiler.cs')
| -rw-r--r-- | src/wixext/BalCompiler.cs | 180 |
1 files changed, 175 insertions, 5 deletions
diff --git a/src/wixext/BalCompiler.cs b/src/wixext/BalCompiler.cs index 484dd9e4..1629a670 100644 --- a/src/wixext/BalCompiler.cs +++ b/src/wixext/BalCompiler.cs | |||
| @@ -9,6 +9,7 @@ namespace WixToolset.Bal | |||
| 9 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 10 | using WixToolset.Data.Symbols; | 10 | using WixToolset.Data.Symbols; |
| 11 | using WixToolset.Extensibility; | 11 | using WixToolset.Extensibility; |
| 12 | using WixToolset.Extensibility.Data; | ||
| 12 | 13 | ||
| 13 | /// <summary> | 14 | /// <summary> |
| 14 | /// The compiler for the WiX Toolset Bal Extension. | 15 | /// The compiler for the WiX Toolset Bal Extension. |
| @@ -17,6 +18,31 @@ namespace WixToolset.Bal | |||
| 17 | { | 18 | { |
| 18 | private readonly Dictionary<string, WixMbaPrereqInformationSymbol> prereqInfoSymbolsByPackageId; | 19 | private readonly Dictionary<string, WixMbaPrereqInformationSymbol> prereqInfoSymbolsByPackageId; |
| 19 | 20 | ||
| 21 | private enum WixDotNetCoreBootstrapperApplicationHostTheme | ||
| 22 | { | ||
| 23 | Unknown, | ||
| 24 | None, | ||
| 25 | Standard, | ||
| 26 | } | ||
| 27 | |||
| 28 | private enum WixManagedBootstrapperApplicationHostTheme | ||
| 29 | { | ||
| 30 | Unknown, | ||
| 31 | None, | ||
| 32 | Standard, | ||
| 33 | } | ||
| 34 | |||
| 35 | private enum WixStandardBootstrapperApplicationTheme | ||
| 36 | { | ||
| 37 | Unknown, | ||
| 38 | HyperlinkLargeLicense, | ||
| 39 | HyperlinkLicense, | ||
| 40 | HyperlinkSidebarLicense, | ||
| 41 | None, | ||
| 42 | RtfLargeLicense, | ||
| 43 | RtfLicense, | ||
| 44 | } | ||
| 45 | |||
| 20 | /// <summary> | 46 | /// <summary> |
| 21 | /// Instantiate a new BalCompiler. | 47 | /// Instantiate a new BalCompiler. |
| 22 | /// </summary> | 48 | /// </summary> |
| @@ -54,7 +80,7 @@ namespace WixToolset.Bal | |||
| 54 | break; | 80 | break; |
| 55 | } | 81 | } |
| 56 | break; | 82 | break; |
| 57 | case "BootstrapperApplicationRef": | 83 | case "BootstrapperApplication": |
| 58 | switch (element.Name.LocalName) | 84 | switch (element.Name.LocalName) |
| 59 | { | 85 | { |
| 60 | case "WixStandardBootstrapperApplication": | 86 | case "WixStandardBootstrapperApplication": |
| @@ -63,8 +89,8 @@ namespace WixToolset.Bal | |||
| 63 | case "WixManagedBootstrapperApplicationHost": | 89 | case "WixManagedBootstrapperApplicationHost": |
| 64 | this.ParseWixManagedBootstrapperApplicationHostElement(intermediate, section, element); | 90 | this.ParseWixManagedBootstrapperApplicationHostElement(intermediate, section, element); |
| 65 | break; | 91 | break; |
| 66 | case "WixDotNetCoreBootstrapperApplication": | 92 | case "WixDotNetCoreBootstrapperApplicationHost": |
| 67 | this.ParseWixDotNetCoreBootstrapperApplicationElement(intermediate, section, element); | 93 | this.ParseWixDotNetCoreBootstrapperApplicationHostElement(intermediate, section, element); |
| 68 | break; | 94 | break; |
| 69 | default: | 95 | default: |
| 70 | this.ParseHelper.UnexpectedElement(parentElement, element); | 96 | this.ParseHelper.UnexpectedElement(parentElement, element); |
| @@ -407,6 +433,7 @@ namespace WixToolset.Bal | |||
| 407 | string licenseUrl = null; | 433 | string licenseUrl = null; |
| 408 | string logoFile = null; | 434 | string logoFile = null; |
| 409 | string logoSideFile = null; | 435 | string logoSideFile = null; |
| 436 | WixStandardBootstrapperApplicationTheme? theme = null; | ||
| 410 | string themeFile = null; | 437 | string themeFile = null; |
| 411 | string localizationFile = null; | 438 | string localizationFile = null; |
| 412 | var suppressOptionsUI = YesNoType.NotSet; | 439 | var suppressOptionsUI = YesNoType.NotSet; |
| @@ -469,6 +496,34 @@ namespace WixToolset.Bal | |||
| 469 | case "SupportCacheOnly": | 496 | case "SupportCacheOnly": |
| 470 | supportCacheOnly = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); | 497 | supportCacheOnly = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); |
| 471 | break; | 498 | break; |
| 499 | case "Theme": | ||
| 500 | var themeValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 501 | switch (themeValue) | ||
| 502 | { | ||
| 503 | case "hyperlinkLargeLicense": | ||
| 504 | theme = WixStandardBootstrapperApplicationTheme.HyperlinkLargeLicense; | ||
| 505 | break; | ||
| 506 | case "hyperlinkLicense": | ||
| 507 | theme = WixStandardBootstrapperApplicationTheme.HyperlinkLicense; | ||
| 508 | break; | ||
| 509 | case "hyperlinkSidebarLicense": | ||
| 510 | theme = WixStandardBootstrapperApplicationTheme.HyperlinkSidebarLicense; | ||
| 511 | break; | ||
| 512 | case "none": | ||
| 513 | theme = WixStandardBootstrapperApplicationTheme.None; | ||
| 514 | break; | ||
| 515 | case "rtfLargeLicense": | ||
| 516 | theme = WixStandardBootstrapperApplicationTheme.RtfLargeLicense; | ||
| 517 | break; | ||
| 518 | case "rtfLicense": | ||
| 519 | theme = WixStandardBootstrapperApplicationTheme.RtfLicense; | ||
| 520 | break; | ||
| 521 | default: | ||
| 522 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Theme", themeValue, "hyperlinkLargeLicense", "hyperlinkLicense", "hyperlinkSidebarLicense", "none", "rtfLargeLicense", "rtfLicense")); | ||
| 523 | theme = WixStandardBootstrapperApplicationTheme.Unknown; // set a value to prevent expected attribute error below. | ||
| 524 | break; | ||
| 525 | } | ||
| 526 | break; | ||
| 472 | default: | 527 | default: |
| 473 | this.ParseHelper.UnexpectedAttribute(node, attrib); | 528 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
| 474 | break; | 529 | break; |
| @@ -482,13 +537,20 @@ namespace WixToolset.Bal | |||
| 482 | 537 | ||
| 483 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); | 538 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
| 484 | 539 | ||
| 485 | if (String.IsNullOrEmpty(licenseFile) && null == licenseUrl) | 540 | if (!theme.HasValue) |
| 541 | { | ||
| 542 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Theme")); | ||
| 543 | } | ||
| 544 | |||
| 545 | if (theme != WixStandardBootstrapperApplicationTheme.None && String.IsNullOrEmpty(licenseFile) && null == licenseUrl) | ||
| 486 | { | 546 | { |
| 487 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); | 547 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); |
| 488 | } | 548 | } |
| 489 | 549 | ||
| 490 | if (!this.Messaging.EncounteredError) | 550 | if (!this.Messaging.EncounteredError) |
| 491 | { | 551 | { |
| 552 | this.CreateBARef(section, sourceLineNumbers, node, "WixStandardBootstrapperApplication"); | ||
| 553 | |||
| 492 | if (!String.IsNullOrEmpty(launchTarget)) | 554 | if (!String.IsNullOrEmpty(launchTarget)) |
| 493 | { | 555 | { |
| 494 | section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchTarget")) | 556 | section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchTarget")) |
| @@ -611,6 +673,31 @@ namespace WixToolset.Bal | |||
| 611 | symbol.SupportCacheOnly = 1; | 673 | symbol.SupportCacheOnly = 1; |
| 612 | } | 674 | } |
| 613 | } | 675 | } |
| 676 | |||
| 677 | string themePayloadGroup = null; | ||
| 678 | switch (theme) | ||
| 679 | { | ||
| 680 | case WixStandardBootstrapperApplicationTheme.HyperlinkLargeLicense: | ||
| 681 | themePayloadGroup = "WixStdbaHyperlinkLargeLicensePayloads"; | ||
| 682 | break; | ||
| 683 | case WixStandardBootstrapperApplicationTheme.HyperlinkLicense: | ||
| 684 | themePayloadGroup = "WixStdbaHyperlinkLicensePayloads"; | ||
| 685 | break; | ||
| 686 | case WixStandardBootstrapperApplicationTheme.HyperlinkSidebarLicense: | ||
| 687 | themePayloadGroup = "WixStdbaHyperlinkSidebarLicensePayloads"; | ||
| 688 | break; | ||
| 689 | case WixStandardBootstrapperApplicationTheme.RtfLargeLicense: | ||
| 690 | themePayloadGroup = "WixStdbaRtfLargeLicensePayloads"; | ||
| 691 | break; | ||
| 692 | case WixStandardBootstrapperApplicationTheme.RtfLicense: | ||
| 693 | themePayloadGroup = "WixStdbaRtfLicensePayloads"; | ||
| 694 | break; | ||
| 695 | } | ||
| 696 | |||
| 697 | if (themePayloadGroup != null) | ||
| 698 | { | ||
| 699 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBundlePayloadGroup, themePayloadGroup); | ||
| 700 | } | ||
| 614 | } | 701 | } |
| 615 | } | 702 | } |
| 616 | 703 | ||
| @@ -624,6 +711,7 @@ namespace WixToolset.Bal | |||
| 624 | string logoFile = null; | 711 | string logoFile = null; |
| 625 | string themeFile = null; | 712 | string themeFile = null; |
| 626 | string localizationFile = null; | 713 | string localizationFile = null; |
| 714 | WixManagedBootstrapperApplicationHostTheme? theme = null; | ||
| 627 | 715 | ||
| 628 | foreach (var attrib in node.Attributes()) | 716 | foreach (var attrib in node.Attributes()) |
| 629 | { | 717 | { |
| @@ -640,6 +728,22 @@ namespace WixToolset.Bal | |||
| 640 | case "LocalizationFile": | 728 | case "LocalizationFile": |
| 641 | localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 729 | localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 642 | break; | 730 | break; |
| 731 | case "Theme": | ||
| 732 | var themeValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 733 | switch (themeValue) | ||
| 734 | { | ||
| 735 | case "none": | ||
| 736 | theme = WixManagedBootstrapperApplicationHostTheme.None; | ||
| 737 | break; | ||
| 738 | case "standard": | ||
| 739 | theme = WixManagedBootstrapperApplicationHostTheme.Standard; | ||
| 740 | break; | ||
| 741 | default: | ||
| 742 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Theme", themeValue, "none", "standard")); | ||
| 743 | theme = WixManagedBootstrapperApplicationHostTheme.Unknown; | ||
| 744 | break; | ||
| 745 | } | ||
| 746 | break; | ||
| 643 | default: | 747 | default: |
| 644 | this.ParseHelper.UnexpectedAttribute(node, attrib); | 748 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
| 645 | break; | 749 | break; |
| @@ -655,6 +759,8 @@ namespace WixToolset.Bal | |||
| 655 | 759 | ||
| 656 | if (!this.Messaging.EncounteredError) | 760 | if (!this.Messaging.EncounteredError) |
| 657 | { | 761 | { |
| 762 | this.CreateBARef(section, sourceLineNumbers, node, "WixManagedBootstrapperApplicationHost"); | ||
| 763 | |||
| 658 | if (!String.IsNullOrEmpty(logoFile)) | 764 | if (!String.IsNullOrEmpty(logoFile)) |
| 659 | { | 765 | { |
| 660 | section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "PreqbaLogo")) | 766 | section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "PreqbaLogo")) |
| @@ -678,6 +784,19 @@ namespace WixToolset.Bal | |||
| 678 | Value = localizationFile, | 784 | Value = localizationFile, |
| 679 | }); | 785 | }); |
| 680 | } | 786 | } |
| 787 | |||
| 788 | string themePayloadGroup = null; | ||
| 789 | switch (theme) | ||
| 790 | { | ||
| 791 | case WixManagedBootstrapperApplicationHostTheme.Standard: | ||
| 792 | themePayloadGroup = "MbaPreqStandardPayloads"; | ||
| 793 | break; | ||
| 794 | } | ||
| 795 | |||
| 796 | if (themePayloadGroup != null) | ||
| 797 | { | ||
| 798 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBundlePayloadGroup, themePayloadGroup); | ||
| 799 | } | ||
| 681 | } | 800 | } |
| 682 | } | 801 | } |
| 683 | 802 | ||
| @@ -685,13 +804,14 @@ namespace WixToolset.Bal | |||
| 685 | /// Parses a WixDotNetCoreBootstrapperApplication element for Bundles. | 804 | /// Parses a WixDotNetCoreBootstrapperApplication element for Bundles. |
| 686 | /// </summary> | 805 | /// </summary> |
| 687 | /// <param name="node">The element to parse.</param> | 806 | /// <param name="node">The element to parse.</param> |
| 688 | private void ParseWixDotNetCoreBootstrapperApplicationElement(Intermediate intermediate, IntermediateSection section, XElement node) | 807 | private void ParseWixDotNetCoreBootstrapperApplicationHostElement(Intermediate intermediate, IntermediateSection section, XElement node) |
| 689 | { | 808 | { |
| 690 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 809 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 691 | string logoFile = null; | 810 | string logoFile = null; |
| 692 | string themeFile = null; | 811 | string themeFile = null; |
| 693 | string localizationFile = null; | 812 | string localizationFile = null; |
| 694 | var selfContainedDeployment = YesNoType.NotSet; | 813 | var selfContainedDeployment = YesNoType.NotSet; |
| 814 | WixDotNetCoreBootstrapperApplicationHostTheme? theme = null; | ||
| 695 | 815 | ||
| 696 | foreach (var attrib in node.Attributes()) | 816 | foreach (var attrib in node.Attributes()) |
| 697 | { | 817 | { |
| @@ -711,6 +831,22 @@ namespace WixToolset.Bal | |||
| 711 | case "SelfContainedDeployment": | 831 | case "SelfContainedDeployment": |
| 712 | selfContainedDeployment = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); | 832 | selfContainedDeployment = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); |
| 713 | break; | 833 | break; |
| 834 | case "Theme": | ||
| 835 | var themeValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 836 | switch (themeValue) | ||
| 837 | { | ||
| 838 | case "none": | ||
| 839 | theme = WixDotNetCoreBootstrapperApplicationHostTheme.None; | ||
| 840 | break; | ||
| 841 | case "standard": | ||
| 842 | theme = WixDotNetCoreBootstrapperApplicationHostTheme.Standard; | ||
| 843 | break; | ||
| 844 | default: | ||
| 845 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Theme", themeValue, "none", "standard")); | ||
| 846 | theme = WixDotNetCoreBootstrapperApplicationHostTheme.Unknown; | ||
| 847 | break; | ||
| 848 | } | ||
| 849 | break; | ||
| 714 | default: | 850 | default: |
| 715 | this.ParseHelper.UnexpectedAttribute(node, attrib); | 851 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
| 716 | break; | 852 | break; |
| @@ -722,10 +858,17 @@ namespace WixToolset.Bal | |||
| 722 | } | 858 | } |
| 723 | } | 859 | } |
| 724 | 860 | ||
| 861 | if (!theme.HasValue) | ||
| 862 | { | ||
| 863 | theme = WixDotNetCoreBootstrapperApplicationHostTheme.Standard; | ||
| 864 | } | ||
| 865 | |||
| 725 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); | 866 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
| 726 | 867 | ||
| 727 | if (!this.Messaging.EncounteredError) | 868 | if (!this.Messaging.EncounteredError) |
| 728 | { | 869 | { |
| 870 | this.CreateBARef(section, sourceLineNumbers, node, "WixDotNetCoreBootstrapperApplicationHost"); | ||
| 871 | |||
| 729 | if (!String.IsNullOrEmpty(logoFile)) | 872 | if (!String.IsNullOrEmpty(logoFile)) |
| 730 | { | 873 | { |
| 731 | section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "DncPreqbaLogo")) | 874 | section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "DncPreqbaLogo")) |
| @@ -757,6 +900,33 @@ namespace WixToolset.Bal | |||
| 757 | SelfContainedDeployment = 1, | 900 | SelfContainedDeployment = 1, |
| 758 | }); | 901 | }); |
| 759 | } | 902 | } |
| 903 | |||
| 904 | string themePayloadGroup = null; | ||
| 905 | switch (theme) | ||
| 906 | { | ||
| 907 | case WixDotNetCoreBootstrapperApplicationHostTheme.Standard: | ||
| 908 | themePayloadGroup = "DncPreqStandardPayloads"; | ||
| 909 | break; | ||
| 910 | } | ||
| 911 | |||
| 912 | if (themePayloadGroup != null) | ||
| 913 | { | ||
| 914 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBundlePayloadGroup, themePayloadGroup); | ||
| 915 | } | ||
| 916 | } | ||
| 917 | } | ||
| 918 | |||
| 919 | private void CreateBARef(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement node, string name) | ||
| 920 | { | ||
| 921 | var id = this.ParseHelper.CreateIdentifierValueFromPlatform(name, this.Context.Platform, BurnPlatforms.X86); | ||
| 922 | if (id == null) | ||
| 923 | { | ||
| 924 | this.Messaging.Write(ErrorMessages.UnsupportedPlatformForElement(sourceLineNumbers, this.Context.Platform.ToString(), node.Name.LocalName)); | ||
| 925 | } | ||
| 926 | |||
| 927 | if (!this.Messaging.EncounteredError) | ||
| 928 | { | ||
| 929 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBootstrapperApplication, id); | ||
| 760 | } | 930 | } |
| 761 | } | 931 | } |
| 762 | } | 932 | } |
