| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | using System.IO; |
| 8 | using Example.Extension; |
| 9 | using WixInternal.TestSupport; |
| 10 | using WixInternal.Core.TestPackage; |
| 11 | using Xunit; |
| 12 | |
| 13 | public class BundleManifestFixture |
| 14 | { |
| 15 | [Fact] |
| 16 | public void PopulatesBAManifestWithBootstrapperApplicationBundleCustomData() |
| 17 | { |
| 18 | var folder = TestData.Get(@"TestData"); |
| 19 | |
| 20 | using (var fs = new DisposableFileSystem()) |
| 21 | { |
| 22 | var baseFolder = fs.GetFolder(); |
| 23 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 24 | var bundlePath = Path.Combine(baseFolder, "bin", "test.exe"); |
| 25 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 26 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 27 | |
| 28 | var result = WixRunner.Execute(new[] |
| 29 | { |
| 30 | "build", |
| 31 | Path.Combine(folder, "BundleCustomTable", "BundleCustomTable.wxs"), |
| 32 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 33 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 34 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 35 | "-intermediateFolder", intermediateFolder, |
| 36 | "-o", bundlePath |
| 37 | }); |
| 38 | |
| 39 | result.AssertSuccess(); |
| 40 | |
| 41 | Assert.True(File.Exists(bundlePath)); |
| 42 | |
| 43 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 44 | extractResult.AssertSuccess(); |
| 45 | |
| 46 | var customElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:BundleCustomTableBA"); |
| 47 | WixAssert.CompareLineByLine(new[] |
| 48 | { |
| 49 | "<BundleCustomTableBA Id='one' Column2='two' />", |
| 50 | "<BundleCustomTableBA Id='>' Column2='<' />", |
| 51 | "<BundleCustomTableBA Id='1' Column2='2' />", |
| 52 | }, customElements); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | [Fact] |
| 57 | public void PopulatesBAManifestWithPackageInformation() |
| 58 | { |
| 59 | var folder = TestData.Get(@"TestData"); |
| 60 | |
| 61 | using (var fs = new DisposableFileSystem()) |
| 62 | { |
| 63 | var baseFolder = fs.GetFolder(); |
| 64 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 65 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 66 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 67 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 68 | |
| 69 | var result = WixRunner.Execute(false, new[] |
| 70 | { |
| 71 | "build", |
| 72 | Path.Combine(folder, "CustomPackageDescription", "CustomPackageDescription.wxs"), |
| 73 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 74 | "-bindpath", Path.Combine(folder, ".Data"), |
| 75 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 76 | "-intermediateFolder", intermediateFolder, |
| 77 | "-o", bundlePath |
| 78 | }); |
| 79 | |
| 80 | result.AssertSuccess(); |
| 81 | |
| 82 | Assert.True(File.Exists(bundlePath)); |
| 83 | |
| 84 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 85 | extractResult.AssertSuccess(); |
| 86 | |
| 87 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 88 | { |
| 89 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize", "InstalledSize", "Version" } }, |
| 90 | }; |
| 91 | var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 92 | WixAssert.CompareLineByLine(new[] |
| 93 | { |
| 94 | "<WixPackageProperties Package='burn.exe' Vital='yes' DisplayName='Windows Installer XML Toolset' Description='WiX Toolset Bootstrapper' DownloadSize='*' PackageSize='*' InstalledSize='*' PackageType='Exe' Permanent='yes' LogPathVariable='WixBundleLog_burn.exe' RollbackLogPathVariable='WixBundleRollbackLog_burn.exe' Compressed='yes' Version='*' RepairCondition='RepairRedists' Cache='keep' />", |
| 95 | "<WixPackageProperties Package='RemotePayloadExe' Vital='yes' DisplayName='Override RemotePayload display name' Description='Override RemotePayload description' DownloadSize='*' PackageSize='*' InstalledSize='*' PackageType='Exe' Permanent='yes' LogPathVariable='WixBundleLog_RemotePayloadExe' RollbackLogPathVariable='WixBundleRollbackLog_RemotePayloadExe' Compressed='no' Version='*' Cache='keep' />", |
| 96 | "<WixPackageProperties Package='calc.exe' Vital='yes' DisplayName='Override harvested display name' Description='Override harvested description' DownloadSize='*' PackageSize='*' InstalledSize='*' PackageType='Exe' Permanent='yes' LogPathVariable='WixBundleLog_calc.exe' RollbackLogPathVariable='WixBundleRollbackLog_calc.exe' Compressed='yes' Version='*' Cache='keep' />", |
| 97 | }, packageElements); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | [Fact] |
| 102 | public void PopulatesBAManifestWithPayloadInformation() |
| 103 | { |
| 104 | var folder = TestData.Get(@"TestData"); |
| 105 | |
| 106 | using (var fs = new DisposableFileSystem()) |
| 107 | { |
| 108 | var baseFolder = fs.GetFolder(); |
| 109 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 110 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 111 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 112 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 113 | |
| 114 | var result = WixRunner.Execute(false, new[] |
| 115 | { |
| 116 | "build", |
| 117 | Path.Combine(folder, "SharedPayloadsBetweenPackages", "SharedPayloadsBetweenPackages.wxs"), |
| 118 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 119 | "-bindpath", Path.Combine(folder, ".Data"), |
| 120 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 121 | "-intermediateFolder", intermediateFolder, |
| 122 | "-o", bundlePath |
| 123 | }); |
| 124 | |
| 125 | result.AssertSuccess(); |
| 126 | |
| 127 | Assert.True(File.Exists(bundlePath)); |
| 128 | |
| 129 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 130 | extractResult.AssertSuccess(); |
| 131 | |
| 132 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 133 | { |
| 134 | { "WixPayloadProperties", new List<string> { "Size" } }, |
| 135 | }; |
| 136 | var payloadElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPayloadProperties", ignoreAttributesByElementName); |
| 137 | WixAssert.CompareLineByLine(new[] |
| 138 | { |
| 139 | "<WixPayloadProperties Package='credwiz.exe' Payload='SourceFilePayload' Container='WixAttachedContainer' Name='SharedPayloadsBetweenPackages.wxs' Size='*' />", |
| 140 | "<WixPayloadProperties Package='credwiz.exe' Payload='credwiz.exe' Container='WixAttachedContainer' Name='credwiz.exe' Size='*' />", |
| 141 | "<WixPayloadProperties Package='cscript.exe' Payload='SourceFilePayload' Container='WixAttachedContainer' Name='SharedPayloadsBetweenPackages.wxs' Size='*' />", |
| 142 | "<WixPayloadProperties Package='cscript.exe' Payload='cscript.exe' Container='WixAttachedContainer' Name='cscript.exe' Size='*' />", |
| 143 | }, payloadElements); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | [Fact] |
| 148 | public void CanBuildBundleManifestWithNormalizedRelatedBundles() |
| 149 | { |
| 150 | var folder = TestData.Get(@"TestData"); |
| 151 | |
| 152 | using (var fs = new DisposableFileSystem()) |
| 153 | { |
| 154 | var baseFolder = fs.GetFolder(); |
| 155 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 156 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 157 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 158 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 159 | |
| 160 | var result = WixRunner.Execute(new[] |
| 161 | { |
| 162 | "build", |
| 163 | Path.Combine(folder, "BundleLocalized", "BundleWithLocalizedUpgradeCode.wxs"), |
| 164 | "-loc", Path.Combine(folder, "BundleLocalized", "BundleWithValidUpgradeCode.wxl"), |
| 165 | "-bindpath", Path.Combine(folder, ".Data"), |
| 166 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 167 | "-intermediateFolder", intermediateFolder, |
| 168 | "-o", Path.Combine(baseFolder, @"bin\test.exe") |
| 169 | }); |
| 170 | |
| 171 | result.AssertSuccess(); |
| 172 | |
| 173 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 174 | extractResult.AssertSuccess(); |
| 175 | |
| 176 | var manifestRelatedBundlesElements = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:RelatedBundle"); |
| 177 | WixAssert.CompareLineByLine(new[] |
| 178 | { |
| 179 | "<RelatedBundle Id='{6D4CE32B-FB91-45DA-A9B5-7E0D9929A3C3}' Action='Upgrade' />", |
| 180 | }, manifestRelatedBundlesElements); |
| 181 | |
| 182 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 183 | { |
| 184 | { "WixBundleProperties", new List<string> { "DisplayName", "Id" } }, |
| 185 | }; |
| 186 | var dataRelatedBundlesElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBundleProperties", ignoreAttributesByElementName); |
| 187 | WixAssert.CompareLineByLine(new[] |
| 188 | { |
| 189 | "<WixBundleProperties DisplayName='*' LogPathVariable='WixBundleLog' Compressed='no' Id='*' UpgradeCode='{6D4CE32B-FB91-45DA-A9B5-7E0D9929A3C3}' PerMachine='yes' />", |
| 190 | }, dataRelatedBundlesElements); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | [Fact] |
| 195 | public void PopulatesBEManifestWithBootstrapperExtensionBundleCustomData() |
| 196 | { |
| 197 | var folder = TestData.Get(@"TestData"); |
| 198 | |
| 199 | using (var fs = new DisposableFileSystem()) |
| 200 | { |
| 201 | var baseFolder = fs.GetFolder(); |
| 202 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 203 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 204 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 205 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 206 | |
| 207 | var result = WixRunner.Execute(new[] |
| 208 | { |
| 209 | "build", |
| 210 | Path.Combine(folder, "BundleCustomTable", "BundleCustomTable.wxs"), |
| 211 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 212 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 213 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 214 | "-intermediateFolder", intermediateFolder, |
| 215 | "-o", bundlePath |
| 216 | }); |
| 217 | |
| 218 | result.AssertSuccess(); |
| 219 | |
| 220 | Assert.True(File.Exists(bundlePath)); |
| 221 | |
| 222 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 223 | extractResult.AssertSuccess(); |
| 224 | |
| 225 | var customElements = extractResult.GetBootstrapperExtensionTestXmlLines("/be:BootstrapperExtensionData/be:BootstrapperExtension[@Id='CustomTableExtension']/be:BundleCustomTableBE"); |
| 226 | WixAssert.CompareLineByLine(new[] |
| 227 | { |
| 228 | "<BundleCustomTableBE Id='one' Column2='two' />", |
| 229 | "<BundleCustomTableBE Id='>' Column2='<' />", |
| 230 | "<BundleCustomTableBE Id='1' Column2='2' />", |
| 231 | }, customElements); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | [Fact] |
| 236 | public void PopulatesManifestWithBootstrapperExtension() |
| 237 | { |
| 238 | var folder = TestData.Get(@"TestData"); |
| 239 | |
| 240 | using (var fs = new DisposableFileSystem()) |
| 241 | { |
| 242 | var baseFolder = fs.GetFolder(); |
| 243 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 244 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 245 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 246 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 247 | |
| 248 | var result = WixRunner.Execute(new[] |
| 249 | { |
| 250 | "build", |
| 251 | Path.Combine(folder, "BootstrapperExtension", "BootstrapperExtension.wxs"), |
| 252 | Path.Combine(folder, "BootstrapperExtension", "SimpleBootstrapperExtension.wxs"), |
| 253 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 254 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 255 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 256 | "-intermediateFolder", intermediateFolder, |
| 257 | "-o", bundlePath |
| 258 | }); |
| 259 | |
| 260 | result.AssertSuccess(); |
| 261 | |
| 262 | Assert.True(File.Exists(bundlePath)); |
| 263 | |
| 264 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 265 | extractResult.AssertSuccess(); |
| 266 | |
| 267 | var bootstrapperExtensions = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:BootstrapperExtension"); |
| 268 | WixAssert.CompareLineByLine(new[] |
| 269 | { |
| 270 | "<BootstrapperExtension Id='ExampleBext' EntryPayloadSourcePath='u1' />", |
| 271 | }, bootstrapperExtensions); |
| 272 | |
| 273 | var bootstrapperExtensionPayloads = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:UX/burn:Payload[@Id='ExampleBext']"); |
| 274 | WixAssert.CompareLineByLine(new[] |
| 275 | { |
| 276 | "<Payload Id='ExampleBext' FilePath='fakebext.dll' SourcePath='u1' />", |
| 277 | }, bootstrapperExtensionPayloads); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | [Fact] |
| 282 | public void PopulatesManifestWithBootstrapperExtensionSearches() |
| 283 | { |
| 284 | var folder = TestData.Get(@"TestData"); |
| 285 | |
| 286 | using (var fs = new DisposableFileSystem()) |
| 287 | { |
| 288 | var baseFolder = fs.GetFolder(); |
| 289 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 290 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 291 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 292 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 293 | |
| 294 | var result = WixRunner.Execute(new[] |
| 295 | { |
| 296 | "build", |
| 297 | Path.Combine(folder, "BootstrapperExtension", "BootstrapperExtensionSearches.wxs"), |
| 298 | Path.Combine(folder, "BootstrapperExtension", "BundleWithSearches.wxs"), |
| 299 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 300 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 301 | "-ext", ExtensionPaths.ExampleExtensionPath, |
| 302 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 303 | "-intermediateFolder", intermediateFolder, |
| 304 | "-o", bundlePath |
| 305 | }); |
| 306 | |
| 307 | result.AssertSuccess(); |
| 308 | |
| 309 | Assert.True(File.Exists(bundlePath)); |
| 310 | |
| 311 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 312 | extractResult.AssertSuccess(); |
| 313 | |
| 314 | var bootstrapperExtensions = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:BootstrapperExtension"); |
| 315 | WixAssert.CompareLineByLine(new[] |
| 316 | { |
| 317 | "<BootstrapperExtension Id='ExampleBootstrapperExtension' EntryPayloadSourcePath='u1' />", |
| 318 | }, bootstrapperExtensions); |
| 319 | |
| 320 | var extensionSearches = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:ExtensionSearch"); |
| 321 | WixAssert.CompareLineByLine(new[] |
| 322 | { |
| 323 | "<ExtensionSearch Id='ExampleSearchBar' Variable='SearchBar' Condition='WixBundleInstalled' ExtensionId='ExampleBootstrapperExtension' />", |
| 324 | "<ExtensionSearch Id='ExampleSearchFoo' Variable='SearchFoo' ExtensionId='ExampleBootstrapperExtension' />", |
| 325 | }, extensionSearches); |
| 326 | |
| 327 | var bootstrapperExtensionDatas = extractResult.GetBootstrapperExtensionTestXmlLines("/be:BootstrapperExtensionData/be:BootstrapperExtension[@Id='ExampleBootstrapperExtension']"); |
| 328 | WixAssert.CompareLineByLine(new[] |
| 329 | { |
| 330 | "<BootstrapperExtension Id='ExampleBootstrapperExtension'>" + |
| 331 | "<ExampleSearch Id='ExampleSearchBar' SearchFor='Bar' />" + |
| 332 | "<ExampleSearch Id='ExampleSearchFoo' SearchFor='Foo' />" + |
| 333 | "</BootstrapperExtension>" |
| 334 | }, bootstrapperExtensionDatas); |
| 335 | |
| 336 | var exampleSearches = extractResult.GetBootstrapperExtensionTestXmlLines("/be:BootstrapperExtensionData/be:BootstrapperExtension[@Id='ExampleBootstrapperExtension']/be:ExampleSearch"); |
| 337 | WixAssert.CompareLineByLine(new[] |
| 338 | { |
| 339 | "<ExampleSearch Id='ExampleSearchBar' SearchFor='Bar' />", |
| 340 | "<ExampleSearch Id='ExampleSearchFoo' SearchFor='Foo' />", |
| 341 | }, exampleSearches); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | [Fact] |
| 346 | public void PopulatesManifestWithExePackages() |
| 347 | { |
| 348 | var folder = TestData.Get(@"TestData"); |
| 349 | |
| 350 | using (var fs = new DisposableFileSystem()) |
| 351 | { |
| 352 | var baseFolder = fs.GetFolder(); |
| 353 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 354 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 355 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 356 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 357 | |
| 358 | var result = WixRunner.Execute(new[] |
| 359 | { |
| 360 | "build", |
| 361 | Path.Combine(folder, "SharedPayloadsBetweenPackages", "SharedPayloadsBetweenPackages.wxs"), |
| 362 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 363 | "-bindpath", Path.Combine(folder, ".Data"), |
| 364 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 365 | "-intermediateFolder", intermediateFolder, |
| 366 | "-o", bundlePath |
| 367 | }); |
| 368 | |
| 369 | result.AssertSuccess(); |
| 370 | |
| 371 | Assert.True(File.Exists(bundlePath)); |
| 372 | |
| 373 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 374 | extractResult.AssertSuccess(); |
| 375 | |
| 376 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 377 | { |
| 378 | { "ExePackage", new List<string> { "CacheId", "InstallSize", "Size" } }, |
| 379 | }; |
| 380 | var exePackageElements = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:ExePackage", ignoreAttributesByElementName); |
| 381 | WixAssert.CompareLineByLine(new[] |
| 382 | { |
| 383 | "<ExePackage Id='credwiz.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' LogPathVariable='WixBundleLog_credwiz.exe' RollbackLogPathVariable='WixBundleRollbackLog_credwiz.exe' InstallArguments='' RepairArguments='' Repairable='no' DetectionType='condition' DetectCondition='none' UninstallArguments='-foo' Uninstallable='yes' Protocol='burn' Bundle='yes'><PayloadRef Id='credwiz.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", |
| 384 | "<ExePackage Id='cscript.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_cscript.exe' RollbackLogPathVariable='WixBundleRollbackLog_cscript.exe' InstallArguments='' RepairArguments='' Repairable='no' DetectionType='condition' DetectCondition='none' UninstallArguments='' Uninstallable='yes' Protocol='none' Bundle='yes'><PayloadRef Id='cscript.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", |
| 385 | }, exePackageElements); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | [Fact] |
| 390 | public void PopulatesManifestWithSetVariables() |
| 391 | { |
| 392 | var folder = TestData.Get(@"TestData"); |
| 393 | |
| 394 | using (var fs = new DisposableFileSystem()) |
| 395 | { |
| 396 | var baseFolder = fs.GetFolder(); |
| 397 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 398 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); |
| 399 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 400 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 401 | |
| 402 | var result = WixRunner.Execute(new[] |
| 403 | { |
| 404 | "build", |
| 405 | Path.Combine(folder, "SetVariable", "Simple.wxs"), |
| 406 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 407 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
| 408 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 409 | "-intermediateFolder", intermediateFolder, |
| 410 | "-o", bundlePath |
| 411 | }); |
| 412 | |
| 413 | result.AssertSuccess(); |
| 414 | |
| 415 | Assert.True(File.Exists(bundlePath)); |
| 416 | |
| 417 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 418 | extractResult.AssertSuccess(); |
| 419 | |
| 420 | var setVariables = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:SetVariable"); |
| 421 | WixAssert.CompareLineByLine(new[] |
| 422 | { |
| 423 | "<SetVariable Id='SetCoercedNumber' Variable='CoercedNumber' Value='2' Type='numeric' />", |
| 424 | "<SetVariable Id='SetCoercedString' Variable='CoercedString' Value='Bar' Type='string' />", |
| 425 | "<SetVariable Id='SetCoercedVersion' Variable='CoercedVersion' Value='v2.0' Type='version' />", |
| 426 | "<SetVariable Id='SetNeedsFormatting' Variable='NeedsFormatting' Value='[One] [Two] [Three]' Type='string' />", |
| 427 | "<SetVariable Id='SetVersionString' Variable='VersionString' Value='v1.0' Type='string' />", |
| 428 | "<SetVariable Id='SetUnset' Variable='Unset' Condition='VersionString = v2.0' />", |
| 429 | }, setVariables); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |