aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--global.json2
-rw-r--r--src/wixext/UtilCompiler.cs209
2 files changed, 84 insertions, 127 deletions
diff --git a/global.json b/global.json
index 4667cc29..efa9830c 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
1{ 1{
2 "msbuild-sdks": { 2 "msbuild-sdks": {
3 "WixToolset.Sdk": "4.0.0-build-0150" 3 "WixToolset.Sdk": "4.0.0-build-0153"
4 }, 4 },
5 "sdk": { 5 "sdk": {
6 "allowPrerelease": false 6 "allowPrerelease": false
diff --git a/src/wixext/UtilCompiler.cs b/src/wixext/UtilCompiler.cs
index fdc1c9eb..a454951e 100644
--- a/src/wixext/UtilCompiler.cs
+++ b/src/wixext/UtilCompiler.cs
@@ -478,7 +478,7 @@ namespace WixToolset.Util
478 string after = null; 478 string after = null;
479 string guid = null; 479 string guid = null;
480 string productCode = null; 480 string productCode = null;
481 var result = Serialize.ComponentSearch.ResultType.NotSet; 481 var attributes = WixComponentSearchAttributes.KeyPath;
482 482
483 foreach (var attrib in element.Attributes()) 483 foreach (var attrib in element.Attributes())
484 { 484 {
@@ -499,14 +499,21 @@ namespace WixToolset.Util
499 productCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib); 499 productCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib);
500 break; 500 break;
501 case "Result": 501 case "Result":
502 var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 502 var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
503 if (!Serialize.ComponentSearch.TryParseResultType(resultValue, out result)) 503 switch (result)
504 { 504 {
505 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 505 case "directory":
506 resultValue, 506 attributes = WixComponentSearchAttributes.WantDirectory;
507 Serialize.ComponentSearch.ResultType.directory.ToString(), 507 break;
508 Serialize.ComponentSearch.ResultType.state.ToString(), 508 case "keyPath":
509 Serialize.ComponentSearch.ResultType.keyPath.ToString())); 509 attributes = WixComponentSearchAttributes.KeyPath;
510 break;
511 case "state":
512 attributes = WixComponentSearchAttributes.State;
513 break;
514 default:
515 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "directory", "keyPath", "state"));
516 break;
510 } 517 }
511 break; 518 break;
512 default: 519 default:
@@ -527,7 +534,7 @@ namespace WixToolset.Util
527 534
528 if (null == id) 535 if (null == id)
529 { 536 {
530 id = this.ParseHelper.CreateIdentifier("wcs", variable, condition, after, guid, productCode, result.ToString()); 537 id = this.ParseHelper.CreateIdentifier("wcs", variable, condition, after, guid, productCode, attributes.ToString());
531 } 538 }
532 539
533 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 540 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -536,20 +543,6 @@ namespace WixToolset.Util
536 543
537 if (!this.Messaging.EncounteredError) 544 if (!this.Messaging.EncounteredError)
538 { 545 {
539 var attributes = WixComponentSearchAttributes.KeyPath;
540 switch (result)
541 {
542 case Serialize.ComponentSearch.ResultType.directory:
543 attributes = WixComponentSearchAttributes.WantDirectory;
544 break;
545 case Serialize.ComponentSearch.ResultType.keyPath:
546 attributes = WixComponentSearchAttributes.KeyPath;
547 break;
548 case Serialize.ComponentSearch.ResultType.state:
549 attributes = WixComponentSearchAttributes.State;
550 break;
551 }
552
553 section.AddSymbol(new WixComponentSearchSymbol(sourceLineNumbers, id) 546 section.AddSymbol(new WixComponentSearchSymbol(sourceLineNumbers, id)
554 { 547 {
555 Guid = guid, 548 Guid = guid,
@@ -1025,7 +1018,7 @@ namespace WixToolset.Util
1025 string condition = null; 1018 string condition = null;
1026 string after = null; 1019 string after = null;
1027 string path = null; 1020 string path = null;
1028 var result = Serialize.DirectorySearch.ResultType.NotSet; 1021 var attributes = WixFileSearchAttributes.IsDirectory;
1029 1022
1030 foreach (var attrib in element.Attributes()) 1023 foreach (var attrib in element.Attributes())
1031 { 1024 {
@@ -1043,11 +1036,15 @@ namespace WixToolset.Util
1043 path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); 1036 path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true);
1044 break; 1037 break;
1045 case "Result": 1038 case "Result":
1046 string resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 1039 var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1047 if (!Serialize.DirectorySearch.TryParseResultType(resultValue, out result)) 1040 switch (result)
1048 { 1041 {
1049 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 1042 case "exists":
1050 resultValue, Serialize.DirectorySearch.ResultType.exists.ToString())); 1043 attributes |= WixFileSearchAttributes.WantExists;
1044 break;
1045 default:
1046 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists"));
1047 break;
1051 } 1048 }
1052 break; 1049 break;
1053 default: 1050 default:
@@ -1068,7 +1065,7 @@ namespace WixToolset.Util
1068 1065
1069 if (null == id) 1066 if (null == id)
1070 { 1067 {
1071 id = this.ParseHelper.CreateIdentifier("wds", variable, condition, after, path, result.ToString()); 1068 id = this.ParseHelper.CreateIdentifier("wds", variable, condition, after, path, attributes.ToString());
1072 } 1069 }
1073 1070
1074 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 1071 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -1077,14 +1074,6 @@ namespace WixToolset.Util
1077 1074
1078 if (!this.Messaging.EncounteredError) 1075 if (!this.Messaging.EncounteredError)
1079 { 1076 {
1080 var attributes = WixFileSearchAttributes.IsDirectory;
1081 switch (result)
1082 {
1083 case Serialize.DirectorySearch.ResultType.exists:
1084 attributes |= WixFileSearchAttributes.WantExists;
1085 break;
1086 }
1087
1088 this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes); 1077 this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes);
1089 } 1078 }
1090 } 1079 }
@@ -1133,7 +1122,7 @@ namespace WixToolset.Util
1133 string condition = null; 1122 string condition = null;
1134 string after = null; 1123 string after = null;
1135 string path = null; 1124 string path = null;
1136 var result = Serialize.FileSearch.ResultType.NotSet; 1125 var attributes = WixFileSearchAttributes.Default;
1137 1126
1138 foreach (var attrib in node.Attributes()) 1127 foreach (var attrib in node.Attributes())
1139 { 1128 {
@@ -1151,13 +1140,18 @@ namespace WixToolset.Util
1151 path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); 1140 path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true);
1152 break; 1141 break;
1153 case "Result": 1142 case "Result":
1154 string resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 1143 string result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1155 if (!Serialize.FileSearch.TryParseResultType(resultValue, out result)) 1144 switch (result)
1156 { 1145 {
1157 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 1146 case "exists":
1158 resultValue, 1147 attributes |= WixFileSearchAttributes.WantExists;
1159 Serialize.FileSearch.ResultType.exists.ToString(), 1148 break;
1160 Serialize.FileSearch.ResultType.version.ToString())); 1149 case "version":
1150 attributes |= WixFileSearchAttributes.WantVersion;
1151 break;
1152 default:
1153 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists", "version"));
1154 break;
1161 } 1155 }
1162 break; 1156 break;
1163 default: 1157 default:
@@ -1178,7 +1172,7 @@ namespace WixToolset.Util
1178 1172
1179 if (null == id) 1173 if (null == id)
1180 { 1174 {
1181 id = this.ParseHelper.CreateIdentifier("wfs", variable, condition, after, path, result.ToString()); 1175 id = this.ParseHelper.CreateIdentifier("wfs", variable, condition, after, path, attributes.ToString());
1182 } 1176 }
1183 1177
1184 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); 1178 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
@@ -1187,17 +1181,6 @@ namespace WixToolset.Util
1187 1181
1188 if (!this.Messaging.EncounteredError) 1182 if (!this.Messaging.EncounteredError)
1189 { 1183 {
1190 var attributes = WixFileSearchAttributes.Default;
1191 switch (result)
1192 {
1193 case Serialize.FileSearch.ResultType.exists:
1194 attributes |= WixFileSearchAttributes.WantExists;
1195 break;
1196 case Serialize.FileSearch.ResultType.version:
1197 attributes |= WixFileSearchAttributes.WantVersion;
1198 break;
1199 }
1200
1201 this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes); 1184 this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes);
1202 } 1185 }
1203 } 1186 }
@@ -2599,8 +2582,7 @@ namespace WixToolset.Util
2599 string after = null; 2582 string after = null;
2600 string productCode = null; 2583 string productCode = null;
2601 string upgradeCode = null; 2584 string upgradeCode = null;
2602 2585 var attributes = WixProductSearchAttributes.Version;
2603 var result = Serialize.ProductSearch.ResultType.NotSet;
2604 2586
2605 foreach (var attrib in element.Attributes()) 2587 foreach (var attrib in element.Attributes())
2606 { 2588 {
@@ -2621,15 +2603,24 @@ namespace WixToolset.Util
2621 upgradeCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib, false); 2603 upgradeCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
2622 break; 2604 break;
2623 case "Result": 2605 case "Result":
2624 var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 2606 var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2625 if (!Serialize.ProductSearch.TryParseResultType(resultValue, out result)) 2607 switch (result)
2626 { 2608 {
2627 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 2609 case "version":
2628 resultValue, 2610 attributes = WixProductSearchAttributes.Version;
2629 Serialize.ProductSearch.ResultType.version.ToString(), 2611 break;
2630 Serialize.ProductSearch.ResultType.language.ToString(), 2612 case "language":
2631 Serialize.ProductSearch.ResultType.state.ToString(), 2613 attributes = WixProductSearchAttributes.Language;
2632 Serialize.ProductSearch.ResultType.assignment.ToString())); 2614 break;
2615 case "state":
2616 attributes = WixProductSearchAttributes.State;
2617 break;
2618 case "assignment":
2619 attributes = WixProductSearchAttributes.Assignment;
2620 break;
2621 default:
2622 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "version", "language", "state", "assignment"));
2623 break;
2633 } 2624 }
2634 break; 2625 break;
2635 default: 2626 default:
@@ -2655,7 +2646,7 @@ namespace WixToolset.Util
2655 2646
2656 if (null == id) 2647 if (null == id)
2657 { 2648 {
2658 id = this.ParseHelper.CreateIdentifier("wps", variable, condition, after, (productCode == null ? upgradeCode : productCode), result.ToString()); 2649 id = this.ParseHelper.CreateIdentifier("wps", variable, condition, after, (productCode == null ? upgradeCode : productCode), attributes.ToString());
2659 } 2650 }
2660 2651
2661 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 2652 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -2664,23 +2655,6 @@ namespace WixToolset.Util
2664 2655
2665 if (!this.Messaging.EncounteredError) 2656 if (!this.Messaging.EncounteredError)
2666 { 2657 {
2667 var attributes = WixProductSearchAttributes.Version;
2668 switch (result)
2669 {
2670 case Serialize.ProductSearch.ResultType.version:
2671 attributes = WixProductSearchAttributes.Version;
2672 break;
2673 case Serialize.ProductSearch.ResultType.language:
2674 attributes = WixProductSearchAttributes.Language;
2675 break;
2676 case Serialize.ProductSearch.ResultType.state:
2677 attributes = WixProductSearchAttributes.State;
2678 break;
2679 case Serialize.ProductSearch.ResultType.assignment:
2680 attributes = WixProductSearchAttributes.Assignment;
2681 break;
2682 }
2683
2684 // set an additional flag if this is an upgrade code 2658 // set an additional flag if this is an upgrade code
2685 if (null != upgradeCode) 2659 if (null != upgradeCode)
2686 { 2660 {
@@ -2711,8 +2685,7 @@ namespace WixToolset.Util
2711 string value = null; 2685 string value = null;
2712 var expand = YesNoType.NotSet; 2686 var expand = YesNoType.NotSet;
2713 var win64 = YesNoType.NotSet; 2687 var win64 = YesNoType.NotSet;
2714 var result = Serialize.RegistrySearch.ResultType.NotSet; 2688 var attributes = WixRegistrySearchAttributes.Raw | WixRegistrySearchAttributes.WantValue;
2715 var format = Serialize.RegistrySearch.FormatType.raw;
2716 2689
2717 foreach (var attrib in element.Attributes()) 2690 foreach (var attrib in element.Attributes())
2718 { 2691 {
@@ -2739,22 +2712,33 @@ namespace WixToolset.Util
2739 expand = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); 2712 expand = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2740 break; 2713 break;
2741 case "Format": 2714 case "Format":
2742 string formatValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 2715 string format = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2743 if (!String.IsNullOrEmpty(formatValue)) 2716 switch (format)
2744 { 2717 {
2745 if (!Serialize.RegistrySearch.TryParseFormatType(formatValue, out format)) 2718 case "raw":
2746 { 2719 attributes |= WixRegistrySearchAttributes.Raw;
2747 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 2720 break;
2748 formatValue, Serialize.RegistrySearch.FormatType.raw.ToString(), Serialize.RegistrySearch.FormatType.compatible.ToString())); 2721 case "compatible":
2749 } 2722 attributes |= WixRegistrySearchAttributes.Compatible;
2723 break;
2724 default:
2725 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, format, "raw", "compatible"));
2726 break;
2750 } 2727 }
2751 break; 2728 break;
2752 case "Result": 2729 case "Result":
2753 var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); 2730 var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2754 if (!Serialize.RegistrySearch.TryParseResultType(resultValue, out result)) 2731 switch (result)
2755 { 2732 {
2756 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, 2733 case "exists":
2757 resultValue, Serialize.RegistrySearch.ResultType.exists.ToString(), Serialize.RegistrySearch.ResultType.value.ToString())); 2734 attributes |= WixRegistrySearchAttributes.WantExists;
2735 break;
2736 case "value":
2737 attributes |= WixRegistrySearchAttributes.WantValue;
2738 break;
2739 default:
2740 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists", "value"));
2741 break;
2758 } 2742 }
2759 break; 2743 break;
2760 case "Win64": 2744 case "Win64":
@@ -2781,43 +2765,16 @@ namespace WixToolset.Util
2781 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Key")); 2765 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Key"));
2782 } 2766 }
2783 2767
2784 if (Serialize.RegistrySearch.ResultType.NotSet == result)
2785 {
2786 result = Serialize.RegistrySearch.ResultType.value;
2787 }
2788
2789 if (null == id) 2768 if (null == id)
2790 { 2769 {
2791 id = this.ParseHelper.CreateIdentifier("wrs", variable, condition, after, root.ToString(), key, value, result.ToString()); 2770 id = this.ParseHelper.CreateIdentifier("wrs", variable, condition, after, root.ToString(), key, value, attributes.ToString());
2792 }
2793
2794 var attributes = WixRegistrySearchAttributes.Raw;
2795 switch (format)
2796 {
2797 case Serialize.RegistrySearch.FormatType.raw:
2798 attributes = WixRegistrySearchAttributes.Raw;
2799 break;
2800 case Serialize.RegistrySearch.FormatType.compatible:
2801 attributes = WixRegistrySearchAttributes.Compatible;
2802 break;
2803 }
2804
2805 switch (result)
2806 {
2807 case Serialize.RegistrySearch.ResultType.exists:
2808 attributes |= WixRegistrySearchAttributes.WantExists;
2809 break;
2810 case Serialize.RegistrySearch.ResultType.value:
2811 attributes |= WixRegistrySearchAttributes.WantValue;
2812 break;
2813 } 2771 }
2814 2772
2815 if (expand == YesNoType.Yes) 2773 if (expand == YesNoType.Yes)
2816 { 2774 {
2817 if (0 != (attributes & WixRegistrySearchAttributes.WantExists)) 2775 if (0 != (attributes & WixRegistrySearchAttributes.WantExists))
2818 { 2776 {
2819 this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, 2777 this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "ExpandEnvironmentVariables", expand.ToString(), "Result", "exists"));
2820 "ExpandEnvironmentVariables", expand.ToString(), "Result", result.ToString()));
2821 } 2778 }
2822 2779
2823 attributes |= WixRegistrySearchAttributes.ExpandEnvironmentVariables; 2780 attributes |= WixRegistrySearchAttributes.ExpandEnvironmentVariables;