aboutsummaryrefslogtreecommitdiff
path: root/src/ext
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-03-15 18:09:12 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-03-16 20:14:37 -0500
commitdb22d99a4d603caab18fd42cb40881431c353912 (patch)
tree93085f239b881010760392d62a695f7717cebb1a /src/ext
parent8c9ca787bee29f969cd7ca9aeaa46626d557d196 (diff)
downloadwix-db22d99a4d603caab18fd42cb40881431c353912.tar.gz
wix-db22d99a4d603caab18fd42cb40881431c353912.tar.bz2
wix-db22d99a4d603caab18fd42cb40881431c353912.zip
Enhance bundle backend validation.
Diffstat (limited to 'src/ext')
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs22
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxl4
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxs2
-rw-r--r--src/ext/Bal/wixext/BalBurnBackendExtension.cs23
4 files changed, 46 insertions, 5 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs b/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs
index ef4ee49a..9aea8c1d 100644
--- a/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs
+++ b/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs
@@ -2,6 +2,7 @@
2 2
3namespace WixToolsetTest.Bal 3namespace WixToolsetTest.Bal
4{ 4{
5 using System;
5 using System.IO; 6 using System.IO;
6 using System.Linq; 7 using System.Linq;
7 using System.Xml; 8 using System.Xml;
@@ -138,20 +139,33 @@ namespace WixToolsetTest.Bal
138 { 139 {
139 var baseFolder = fs.GetFolder(); 140 var baseFolder = fs.GetFolder();
140 var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); 141 var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
141 var bundleSourceFolder = TestData.Get(@"TestData\Overridable"); 142 var bundleSourceFolder = TestData.Get(@"TestData");
142 var intermediateFolder = Path.Combine(baseFolder, "obj"); 143 var intermediateFolder = Path.Combine(baseFolder, "obj");
143 var baFolderPath = Path.Combine(baseFolder, "ba"); 144 var baFolderPath = Path.Combine(baseFolder, "ba");
144 var extractFolderPath = Path.Combine(baseFolder, "extract"); 145 var extractFolderPath = Path.Combine(baseFolder, "extract");
145 146
146 var compileResult = WixRunner.Execute(new[] 147 var result = WixRunner.Execute(new[]
147 { 148 {
148 "build", 149 "build",
149 Path.Combine(bundleSourceFolder, "WrongCaseBundle.wxs"), 150 Path.Combine(bundleSourceFolder, "Overridable", "WrongCaseBundle.wxs"),
151 "-loc", Path.Combine(bundleSourceFolder, "Overridable", "WrongCaseBundle.wxl"),
152 "-bindpath", Path.Combine(bundleSourceFolder, "WixStdBa", "Data"),
150 "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"), 153 "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"),
151 "-intermediateFolder", intermediateFolder, 154 "-intermediateFolder", intermediateFolder,
152 "-o", bundleFile, 155 "-o", bundleFile,
153 }); 156 });
154 Assert.Equal((int)BalErrors.Ids.NonUpperCaseOverridableVariable, compileResult.ExitCode); 157
158 Assert.InRange(result.ExitCode, 2, Int32.MaxValue);
159
160 var messages = result.Messages.Select(m => m.ToString()).ToList();
161 messages.Sort();
162
163 WixAssert.CompareLineByLine(new[]
164 {
165 "bal:Condition/@Condition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.",
166 "Overridable variable 'Test1' must be 'TEST1' with Bundle/@CommandLineVariables value 'upperCase'.",
167 "The *Package/@bal:DisplayInternalUICondition attribute's value '=' is not a valid bundle condition.",
168 }, messages.ToArray());
155 } 169 }
156 } 170 }
157 } 171 }
diff --git a/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxl b/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxl
new file mode 100644
index 00000000..223a7874
--- /dev/null
+++ b/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxl
@@ -0,0 +1,4 @@
1<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
2 <String Id="NonsenseDetectCondition">WixBundleAction = 4</String>
3 <String Id="NonsensePlanCondition">=</String>
4</WixLocalization>
diff --git a/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxs b/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxs
index 91380c69..547af644 100644
--- a/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxs
+++ b/src/ext/Bal/test/WixToolsetTest.Bal/TestData/Overridable/WrongCaseBundle.wxs
@@ -8,6 +8,8 @@
8 <Variable Name="Test1" bal:Overridable="yes" /> 8 <Variable Name="Test1" bal:Overridable="yes" />
9 <Chain> 9 <Chain>
10 <ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" /> 10 <ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" />
11 <MsiPackage SourceFile="test.msi" bal:DisplayInternalUICondition="!(loc.NonsensePlanCondition)" />
11 </Chain> 12 </Chain>
13 <bal:Condition Condition="!(loc.NonsenseDetectCondition)" Message="Unsupported" />
12 </Bundle> 14 </Bundle>
13</Wix> 15</Wix>
diff --git a/src/ext/Bal/wixext/BalBurnBackendExtension.cs b/src/ext/Bal/wixext/BalBurnBackendExtension.cs
index 854b8b35..3b19ae78 100644
--- a/src/ext/Bal/wixext/BalBurnBackendExtension.cs
+++ b/src/ext/Bal/wixext/BalBurnBackendExtension.cs
@@ -10,6 +10,7 @@ namespace WixToolset.Bal
10 using WixToolset.Data.Burn; 10 using WixToolset.Data.Burn;
11 using WixToolset.Data.Symbols; 11 using WixToolset.Data.Symbols;
12 using WixToolset.Extensibility; 12 using WixToolset.Extensibility;
13 using WixToolset.Extensibility.Data;
13 14
14 public class BalBurnBackendExtension : BaseBurnBackendBinderExtension 15 public class BalBurnBackendExtension : BaseBurnBackendBinderExtension
15 { 16 {
@@ -31,6 +32,8 @@ namespace WixToolset.Bal
31 { 32 {
32 base.SymbolsFinalized(section); 33 base.SymbolsFinalized(section);
33 34
35 this.VerifyBalConditions(section);
36 this.VerifyBalPackageInfos(section);
34 this.VerifyOverridableVariables(section); 37 this.VerifyOverridableVariables(section);
35 38
36 var baSymbol = section.Symbols.OfType<WixBootstrapperApplicationDllSymbol>().SingleOrDefault(); 39 var baSymbol = section.Symbols.OfType<WixBootstrapperApplicationDllSymbol>().SingleOrDefault();
@@ -100,7 +103,7 @@ namespace WixToolset.Bal
100 { 103 {
101 foreach (var payloadPropertiesSymbol in payloadPropertiesSymbols) 104 foreach (var payloadPropertiesSymbol in payloadPropertiesSymbols)
102 { 105 {
103 if (string.Equals(payloadPropertiesSymbol.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase) && 106 if (String.Equals(payloadPropertiesSymbol.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase) &&
104 BurnConstants.BurnUXContainerName == payloadPropertiesSymbol.ContainerRef) 107 BurnConstants.BurnUXContainerName == payloadPropertiesSymbol.ContainerRef)
105 { 108 {
106 this.Messaging.Write(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesSymbol.SourceLineNumbers)); 109 this.Messaging.Write(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesSymbol.SourceLineNumbers));
@@ -120,6 +123,24 @@ namespace WixToolset.Bal
120 } 123 }
121 } 124 }
122 125
126 private void VerifyBalConditions(IntermediateSection section)
127 {
128 var balConditionSymbols = section.Symbols.OfType<WixBalConditionSymbol>().ToList();
129 foreach (var balConditionSymbol in balConditionSymbols)
130 {
131 this.BackendHelper.ValidateBundleCondition(balConditionSymbol.SourceLineNumbers, "bal:Condition", "Condition", balConditionSymbol.Condition, BundleConditionPhase.Detect);
132 }
133 }
134
135 private void VerifyBalPackageInfos(IntermediateSection section)
136 {
137 var balPackageInfoSymbols = section.Symbols.OfType<WixBalPackageInfoSymbol>().ToList();
138 foreach (var balPackageInfoSymbol in balPackageInfoSymbols)
139 {
140 this.BackendHelper.ValidateBundleCondition(balPackageInfoSymbol.SourceLineNumbers, "*Package", "bal:DisplayInternalUICondition", balPackageInfoSymbol.DisplayInternalUICondition, BundleConditionPhase.Plan);
141 }
142 }
143
123 private void VerifyOverridableVariables(IntermediateSection section) 144 private void VerifyOverridableVariables(IntermediateSection section)
124 { 145 {
125 var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); 146 var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single();