diff options
9 files changed, 178 insertions, 4 deletions
diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index 57069902..9b0bebc1 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs | |||
@@ -2274,15 +2274,17 @@ namespace WixToolset.Converters | |||
2274 | private static bool TryGetInnerText(XElement element, out string value) | 2274 | private static bool TryGetInnerText(XElement element, out string value) |
2275 | { | 2275 | { |
2276 | value = null; | 2276 | value = null; |
2277 | var found = false; | ||
2277 | 2278 | ||
2278 | var nodes = element.Nodes(); | 2279 | var nodes = element.Nodes().ToList(); |
2279 | 2280 | ||
2280 | if (nodes.All(e => e.NodeType == XmlNodeType.Text || e.NodeType == XmlNodeType.CDATA)) | 2281 | if (nodes.Any() && nodes.All(e => e.NodeType == XmlNodeType.Text || e.NodeType == XmlNodeType.CDATA)) |
2281 | { | 2282 | { |
2282 | value = String.Join(String.Empty, nodes.Cast<XText>().Select(TrimTextValue)); | 2283 | value = String.Join(String.Empty, nodes.Cast<XText>().Select(TrimTextValue)); |
2284 | found = true; | ||
2283 | } | 2285 | } |
2284 | 2286 | ||
2285 | return !String.IsNullOrEmpty(value); | 2287 | return found; |
2286 | } | 2288 | } |
2287 | 2289 | ||
2288 | private static bool IsTextNode(XNode node, out XText text) | 2290 | private static bool IsTextNode(XNode node, out XText text) |
diff --git a/src/wix/test/WixToolsetTest.Converters/ConditionFixture.cs b/src/wix/test/WixToolsetTest.Converters/ConditionFixture.cs index d3f65aeb..daf66a8b 100644 --- a/src/wix/test/WixToolsetTest.Converters/ConditionFixture.cs +++ b/src/wix/test/WixToolsetTest.Converters/ConditionFixture.cs | |||
@@ -140,6 +140,115 @@ namespace WixToolsetTest.Converters | |||
140 | } | 140 | } |
141 | 141 | ||
142 | [Fact] | 142 | [Fact] |
143 | public void FixEmptyCondition() | ||
144 | { | ||
145 | var parse = String.Join(Environment.NewLine, | ||
146 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
147 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
148 | " <Fragment>", | ||
149 | " <Condition Message='Empty new line'>", | ||
150 | " </Condition>", | ||
151 | " <Condition Message='Empty cdata'><![CDATA[]]></Condition>", | ||
152 | " </Fragment>", | ||
153 | "</Wix>"); | ||
154 | |||
155 | var expected = new[] | ||
156 | { | ||
157 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
158 | " <Fragment>", | ||
159 | " <Launch Condition=\"\" Message=\"Empty new line\" />", | ||
160 | " <Launch Condition=\"\" Message=\"Empty cdata\" />", | ||
161 | " </Fragment>", | ||
162 | "</Wix>" | ||
163 | }; | ||
164 | |||
165 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
166 | |||
167 | var messaging = new MockMessaging(); | ||
168 | var converter = new WixConverter(messaging, 2, null, null); | ||
169 | |||
170 | var errors = converter.ConvertDocument(document); | ||
171 | |||
172 | var actualLines = UnformattedDocumentLines(document); | ||
173 | WixAssert.CompareLineByLine(expected, actualLines); | ||
174 | |||
175 | Assert.Equal(4, errors); | ||
176 | } | ||
177 | |||
178 | [Fact(Skip = "Test demonstrates failure")] | ||
179 | public void FixConditionWithComment() | ||
180 | { | ||
181 | var parse = String.Join(Environment.NewLine, | ||
182 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
183 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
184 | " <Fragment>", | ||
185 | " <Condition Message='commented cdata'>", | ||
186 | " <!-- commented condition -->", | ||
187 | " <![CDATA[cdatacontent]]>", | ||
188 | " </Condition>", | ||
189 | " </Fragment>", | ||
190 | "</Wix>"); | ||
191 | |||
192 | //TODO: expected value is not set in stone but must have replaced Condition element with Launch and should have kept the comment. | ||
193 | var expected = new[] | ||
194 | { | ||
195 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
196 | " <Fragment>", | ||
197 | " <Launch Condition=\"cdatacontent\" Message=\"commented cdata\" />", | ||
198 | " <!-- commented condition -->", | ||
199 | " </Fragment>", | ||
200 | "</Wix>" | ||
201 | }; | ||
202 | |||
203 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
204 | |||
205 | var messaging = new MockMessaging(); | ||
206 | var converter = new WixConverter(messaging, 2, null, null); | ||
207 | |||
208 | var errors = converter.ConvertDocument(document); | ||
209 | |||
210 | var actualLines = UnformattedDocumentLines(document); | ||
211 | WixAssert.CompareLineByLine(expected, actualLines); | ||
212 | |||
213 | Assert.Equal(2, errors); | ||
214 | } | ||
215 | |||
216 | [Fact] | ||
217 | public void FixConditionFromWxi() | ||
218 | { | ||
219 | var parse = String.Join(Environment.NewLine, | ||
220 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
221 | "<Include xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
222 | " <Fragment>", | ||
223 | " <Condition Message='from wxi'>", | ||
224 | " wxicondition", | ||
225 | " </Condition>", | ||
226 | " </Fragment>", | ||
227 | "</Include>"); | ||
228 | |||
229 | var expected = new[] | ||
230 | { | ||
231 | "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
232 | " <Fragment>", | ||
233 | " <Launch Condition=\"wxicondition\" Message=\"from wxi\" />", | ||
234 | " </Fragment>", | ||
235 | "</Include>" | ||
236 | }; | ||
237 | |||
238 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
239 | |||
240 | var messaging = new MockMessaging(); | ||
241 | var converter = new WixConverter(messaging, 2, null, null); | ||
242 | |||
243 | var errors = converter.ConvertDocument(document); | ||
244 | |||
245 | var actualLines = UnformattedDocumentLines(document); | ||
246 | WixAssert.CompareLineByLine(expected, actualLines); | ||
247 | |||
248 | Assert.Equal(3, errors); | ||
249 | } | ||
250 | |||
251 | [Fact] | ||
143 | public void FixFeatureCondition() | 252 | public void FixFeatureCondition() |
144 | { | 253 | { |
145 | var parse = String.Join(Environment.NewLine, | 254 | var parse = String.Join(Environment.NewLine, |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index 132e93e6..c7dd4cfa 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | |||
@@ -307,6 +307,43 @@ namespace WixToolsetTest.CoreIntegration | |||
307 | } | 307 | } |
308 | 308 | ||
309 | [Fact] | 309 | [Fact] |
310 | public void CanBuildSimpleBundleUsingInclude() | ||
311 | { | ||
312 | var folder = TestData.Get(@"TestData", "IncludePath"); | ||
313 | var dataFolder = TestData.Get(@"TestData", "SimpleBundle", "data"); | ||
314 | |||
315 | using (var fs = new DisposableFileSystem()) | ||
316 | { | ||
317 | var baseFolder = fs.GetFolder(); | ||
318 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
319 | var exePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
320 | var pdbPath = Path.Combine(baseFolder, @"bin\test.wixpdb"); | ||
321 | |||
322 | var result = WixRunner.Execute(new[] | ||
323 | { | ||
324 | "build", | ||
325 | Path.Combine(folder, "Bundle.wxs"), | ||
326 | "-loc", Path.Combine(folder, "Bundle.en-us.wxl"), | ||
327 | "-bindpath", dataFolder, | ||
328 | "-intermediateFolder", intermediateFolder, | ||
329 | "-o", exePath, | ||
330 | }); | ||
331 | |||
332 | result.AssertSuccess(); | ||
333 | |||
334 | using (var wixOutput = WixOutput.Read(pdbPath)) | ||
335 | { | ||
336 | |||
337 | var intermediate = Intermediate.Load(wixOutput); | ||
338 | var section = intermediate.Sections.Single(); | ||
339 | |||
340 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
341 | WixAssert.StringEqual("~IncludeTestBundle", bundleSymbol.Name); | ||
342 | } | ||
343 | } | ||
344 | } | ||
345 | |||
346 | [Fact] | ||
310 | public void CanBuildSingleExeBundle() | 347 | public void CanBuildSingleExeBundle() |
311 | { | 348 | { |
312 | var folder = TestData.Get(@"TestData"); | 349 | var folder = TestData.Get(@"TestData"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index c1c07952..0c01fa5e 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs | |||
@@ -535,6 +535,9 @@ namespace WixToolsetTest.CoreIntegration | |||
535 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); | 535 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); |
536 | WixAssert.StringEqual(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path); | 536 | WixAssert.StringEqual(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path); |
537 | WixAssert.StringEqual(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); | 537 | WixAssert.StringEqual(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); |
538 | |||
539 | var featureSymbol = Assert.Single(section.Symbols.OfType<FeatureSymbol>()); | ||
540 | WixAssert.StringEqual("MsiPackage", featureSymbol.Title); | ||
538 | } | 541 | } |
539 | } | 542 | } |
540 | 543 | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.en-us.wxl b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.en-us.wxl new file mode 100644 index 00000000..fb2131ce --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.en-us.wxl | |||
@@ -0,0 +1,6 @@ | |||
1 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
2 | |||
3 | <String Id="BundleName">~IncludeTestBundle</String> | ||
4 | <String Id="BundleInProgressName">~InProgressTestBundle</String> | ||
5 | |||
6 | </WixLocalization> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.wxs new file mode 100644 index 00000000..5e001c9a --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Bundle.wxs | |||
@@ -0,0 +1,13 @@ | |||
1 | <?include data\Bundle.wxi ?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Bundle Name="$(var.BundleLocName)" InProgressName="!(loc.BundleInProgressName)" Version="!(bind.packageVersion.test.msi)" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
4 | <BootstrapperApplication> | ||
5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | ||
6 | </BootstrapperApplication> | ||
7 | <Chain> | ||
8 | <MsiPackage SourceFile="test.msi"> | ||
9 | <MsiProperty Name="TEST" Value="1" /> | ||
10 | </MsiPackage> | ||
11 | </Chain> | ||
12 | </Bundle> | ||
13 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs index 0bd80c50..2f789908 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | 6 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> |
7 | 7 | ||
8 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | 8 | <Feature Id="ProductFeature" Title="$(var.FeatureTitleName)"> |
9 | <ComponentGroupRef Id="ProductComponents" /> | 9 | <ComponentGroupRef Id="ProductComponents" /> |
10 | </Feature> | 10 | </Feature> |
11 | </Package> | 11 | </Package> |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Bundle.wxi b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Bundle.wxi new file mode 100644 index 00000000..0ad96e6c --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Bundle.wxi | |||
@@ -0,0 +1,3 @@ | |||
1 | <Include xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <?define BundleLocName = "!(loc.BundleName)" ?> | ||
3 | </Include> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Package.wxi b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Package.wxi index f2df3b86..76ebfad6 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Package.wxi +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/data/Package.wxi | |||
@@ -1,4 +1,5 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <Include xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Include xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <?define ProductVersion = "1.2.3" ?> | 3 | <?define ProductVersion = "1.2.3" ?> |
4 | <?define FeatureTitleName = "!(loc.FeatureTitle)" ?> | ||
4 | </Include> | 5 | </Include> |