| 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.Collections.Generic; |
| 6 | using System.IO; |
| 7 | using System.Linq; |
| 8 | using System.Xml; |
| 9 | using WixInternal.TestSupport; |
| 10 | using WixInternal.Core.TestPackage; |
| 11 | using WixToolset.Data; |
| 12 | using WixToolset.Data.Symbols; |
| 13 | using Xunit; |
| 14 | |
| 15 | public class BundlePackageFixture |
| 16 | { |
| 17 | [Fact] |
| 18 | public void CanBuildBundleWithBundlePackage() |
| 19 | { |
| 20 | var folder = TestData.Get(@"TestData"); |
| 21 | |
| 22 | using (var fs = new DisposableFileSystem()) |
| 23 | { |
| 24 | var baseFolder = fs.GetFolder(); |
| 25 | var chainIntermediateFolder = Path.Combine(baseFolder, "obj", "Chain"); |
| 26 | var parentIntermediateFolder = Path.Combine(baseFolder, "obj", "Parent"); |
| 27 | var grandparentIntermediateFolder = Path.Combine(baseFolder, "obj", "Grandparent"); |
| 28 | var binFolder = Path.Combine(baseFolder, "bin"); |
| 29 | var chainBundlePath = Path.Combine(binFolder, "chain.exe"); |
| 30 | var chainPdbPath = Path.Combine(binFolder, "chain.wixpdb"); |
| 31 | var parentBundlePath = Path.Combine(binFolder, "parent.exe"); |
| 32 | var parentPdbPath = Path.Combine(binFolder, "parent.wixpdb"); |
| 33 | var grandparentBundlePath = Path.Combine(binFolder, "grandparent.exe"); |
| 34 | var grandparentPdbPath = Path.Combine(binFolder, "grandparent.wixpdb"); |
| 35 | var parentBaFolderPath = Path.Combine(baseFolder, "parentba"); |
| 36 | var grandparentBaFolderPath = Path.Combine(baseFolder, "grandparentba"); |
| 37 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 38 | |
| 39 | // chain.exe |
| 40 | var result = WixRunner.Execute(new[] |
| 41 | { |
| 42 | "build", |
| 43 | Path.Combine(folder, "Dependency", "CustomProviderKeyBundle.wxs"), |
| 44 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), |
| 45 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 46 | "-intermediateFolder", chainIntermediateFolder, |
| 47 | "-o", chainBundlePath, |
| 48 | }); |
| 49 | |
| 50 | result.AssertSuccess(); |
| 51 | |
| 52 | Assert.True(File.Exists(chainBundlePath)); |
| 53 | |
| 54 | var chainBundleId = GetBundleIdFromWixpdb(chainPdbPath); |
| 55 | |
| 56 | // parent.exe |
| 57 | result = WixRunner.Execute(new[] |
| 58 | { |
| 59 | "build", |
| 60 | Path.Combine(folder, "BundlePackage", "BundlePackage.wxs"), |
| 61 | "-bindpath", Path.Combine(folder, ".Data"), |
| 62 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 63 | "-bindpath", binFolder, |
| 64 | "-intermediateFolder", parentIntermediateFolder, |
| 65 | "-o", parentBundlePath, |
| 66 | }); |
| 67 | |
| 68 | result.AssertSuccess(); |
| 69 | |
| 70 | Assert.True(File.Exists(parentBundlePath)); |
| 71 | |
| 72 | var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); |
| 73 | |
| 74 | var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, parentBaFolderPath, extractFolderPath); |
| 75 | extractResult.AssertSuccess(); |
| 76 | |
| 77 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 78 | { |
| 79 | { "BundlePackage", new List<string> { "Size" } }, |
| 80 | }; |
| 81 | var bundlePackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:BundlePackage", ignoreAttributesByElementName); |
| 82 | WixAssert.CompareLineByLine(new[] |
| 83 | { |
| 84 | $"<BundlePackage Id='chain.exe' Cache='keep' CacheId='{chainBundleId}v1.0.0.0' InstallSize='34' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_chain.exe' RollbackLogPathVariable='WixBundleRollbackLog_chain.exe' BundleId='{chainBundleId}' Version='1.0.0.0' InstallArguments='' UninstallArguments='' RepairArguments='' SupportsBurnProtocol='yes' Win64='no' HideARP='yes'>" + |
| 85 | "<Provides Key='MyProviderKey,v1.0' Version='1.0.0.0' DisplayName='BurnBundle' Imported='yes' />" + |
| 86 | "<RelatedBundle Id='{B94478B1-E1F3-4700-9CE8-6AA090854AEC}' Action='Upgrade' />" + |
| 87 | "<PayloadRef Id='chain.exe' />" + |
| 88 | "<PayloadRef Id='paydfjdGCAZtFxTeTjs0nIscHI86SY' />" + |
| 89 | "</BundlePackage>", |
| 90 | }, bundlePackages); |
| 91 | |
| 92 | var registrations = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); |
| 93 | WixAssert.CompareLineByLine(new[] |
| 94 | { |
| 95 | $"<Registration Id='{parentBundleId}' ExecutableName='parent.exe' PerMachine='yes' Tag='' Version='1.0.1.0' ProviderKey='{parentBundleId}'>" + |
| 96 | "<Arp DisplayName='BundlePackageBundle' DisplayVersion='1.0.1.0' Publisher='Example Corporation' />" + |
| 97 | "</Registration>" |
| 98 | }, registrations); |
| 99 | |
| 100 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 101 | { |
| 102 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize" } }, |
| 103 | }; |
| 104 | var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 105 | WixAssert.CompareLineByLine(new[] |
| 106 | { |
| 107 | "<WixPackageProperties Package='chain.exe' Vital='yes' DisplayName='BurnBundle' Description='BurnBundle' DownloadSize='*' PackageSize='*' InstalledSize='34' PackageType='Bundle' Permanent='yes' LogPathVariable='WixBundleLog_chain.exe' RollbackLogPathVariable='WixBundleRollbackLog_chain.exe' Compressed='no' Version='1.0.0.0' Cache='keep' />", |
| 108 | }, packageElements); |
| 109 | |
| 110 | // grandparent.exe |
| 111 | result = WixRunner.Execute(new[] |
| 112 | { |
| 113 | "build", |
| 114 | Path.Combine(folder, "BundlePackage", "PermanentBundlePackage.wxs"), |
| 115 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 116 | "-bindpath", binFolder, |
| 117 | "-intermediateFolder", grandparentIntermediateFolder, |
| 118 | "-o", grandparentBundlePath, |
| 119 | }); |
| 120 | |
| 121 | result.AssertSuccess(); |
| 122 | |
| 123 | Assert.True(File.Exists(grandparentBundlePath)); |
| 124 | |
| 125 | var grandparentBundleId = GetBundleIdFromWixpdb(grandparentPdbPath); |
| 126 | |
| 127 | var grandparentExtractResult = BundleExtractor.ExtractBAContainer(null, grandparentBundlePath, grandparentBaFolderPath, extractFolderPath); |
| 128 | grandparentExtractResult.AssertSuccess(); |
| 129 | |
| 130 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 131 | { |
| 132 | { "BundlePackage", new List<string> { "Size" } }, |
| 133 | }; |
| 134 | bundlePackages = grandparentExtractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:BundlePackage", ignoreAttributesByElementName); |
| 135 | WixAssert.CompareLineByLine(new[] |
| 136 | { |
| 137 | $"<BundlePackage Id='parent.exe' Cache='keep' CacheId='{parentBundleId}v1.0.1.0' InstallSize='34' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_parent.exe' RollbackLogPathVariable='WixBundleRollbackLog_parent.exe' BundleId='{parentBundleId}' Version='1.0.1.0' InstallArguments='' UninstallArguments='' RepairArguments='' SupportsBurnProtocol='yes' Win64='no'>" + |
| 138 | $"<Provides Key='{parentBundleId}' Version='1.0.1.0' DisplayName='BundlePackageBundle' Imported='yes' />" + |
| 139 | "<RelatedBundle Id='{4BE34BEE-CA23-488E-96A0-B15878E3654B}' Action='Upgrade' />" + |
| 140 | "<PayloadRef Id='parent.exe' />" + |
| 141 | "</BundlePackage>", |
| 142 | }, bundlePackages); |
| 143 | |
| 144 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 145 | { |
| 146 | { "Payload", new List<string> { "FileSize", "Hash" } }, |
| 147 | }; |
| 148 | var payloads = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Payload", ignoreAttributesByElementName); |
| 149 | WixAssert.CompareLineByLine(new[] |
| 150 | { |
| 151 | "<Payload Id='paydfjdGCAZtFxTeTjs0nIscHI86SY' FilePath='signed_cab1.cab' FileSize='*' Hash='*' Packaging='external' SourcePath='signed_cab1.cab' />", |
| 152 | "<Payload Id='chain.exe' FilePath='chain.exe' FileSize='*' Hash='*' Packaging='external' SourcePath='chain.exe' />", |
| 153 | }, payloads); |
| 154 | |
| 155 | registrations = grandparentExtractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); |
| 156 | WixAssert.CompareLineByLine(new[] |
| 157 | { |
| 158 | $"<Registration Id='{grandparentBundleId}' ExecutableName='grandparent.exe' PerMachine='yes' Tag='' Version='1.0.2.0' ProviderKey='{grandparentBundleId}'>" + |
| 159 | "<Arp DisplayName='PermanentBundlePackageBundle' DisplayVersion='1.0.2.0' Publisher='Example Corporation' />" + |
| 160 | "</Registration>" |
| 161 | }, registrations); |
| 162 | |
| 163 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 164 | { |
| 165 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize" } }, |
| 166 | }; |
| 167 | packageElements = grandparentExtractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 168 | WixAssert.CompareLineByLine(new[] |
| 169 | { |
| 170 | "<WixPackageProperties Package='parent.exe' Vital='yes' DisplayName='BundlePackageBundle' Description='BundlePackageBundle' DownloadSize='*' PackageSize='*' InstalledSize='34' PackageType='Bundle' Permanent='yes' LogPathVariable='WixBundleLog_parent.exe' RollbackLogPathVariable='WixBundleRollbackLog_parent.exe' Compressed='yes' Version='1.0.1.0' Cache='keep' />", |
| 171 | }, packageElements); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | [Fact] |
| 176 | public void CanBuildBundleWithRemoteBundlePackage() |
| 177 | { |
| 178 | var folder = TestData.Get(@"TestData"); |
| 179 | |
| 180 | using (var fs = new DisposableFileSystem()) |
| 181 | { |
| 182 | var baseFolder = fs.GetFolder(); |
| 183 | var parentIntermediateFolder = Path.Combine(baseFolder, "obj", "Parent"); |
| 184 | var binFolder = Path.Combine(baseFolder, "bin"); |
| 185 | var parentBundlePath = Path.Combine(binFolder, "parent.exe"); |
| 186 | var parentPdbPath = Path.Combine(binFolder, "parent.wixpdb"); |
| 187 | var parentBaFolderPath = Path.Combine(baseFolder, "parentba"); |
| 188 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 189 | |
| 190 | var result = WixRunner.Execute(new[] |
| 191 | { |
| 192 | "build", |
| 193 | Path.Combine(folder, "BundlePackage", "RemoteBundlePackage.wxs"), |
| 194 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 195 | "-bindpath", binFolder, |
| 196 | "-intermediateFolder", parentIntermediateFolder, |
| 197 | "-o", parentBundlePath, |
| 198 | }); |
| 199 | |
| 200 | result.AssertSuccess(); |
| 201 | |
| 202 | Assert.True(File.Exists(parentBundlePath)); |
| 203 | |
| 204 | var chainBundleId = "{216BDA7F-74BD-45E8-957B-500552F05629}"; |
| 205 | |
| 206 | var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); |
| 207 | |
| 208 | var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, parentBaFolderPath, extractFolderPath); |
| 209 | extractResult.AssertSuccess(); |
| 210 | |
| 211 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 212 | { |
| 213 | { "BundlePackage", new List<string> { "Size" } }, |
| 214 | }; |
| 215 | var bundlePackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:BundlePackage", ignoreAttributesByElementName); |
| 216 | WixAssert.CompareLineByLine(new[] |
| 217 | { |
| 218 | $"<BundlePackage Id='chain.exe' Cache='keep' CacheId='{chainBundleId}v1.0.0-foo.55' InstallSize='34' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_chain.exe' RollbackLogPathVariable='WixBundleRollbackLog_chain.exe' BundleId='{chainBundleId}' Version='1.0.0-foo.55' InstallArguments='' UninstallArguments='' RepairArguments='' SupportsBurnProtocol='yes' Win64='no'>" + |
| 219 | "<Provides Key='MyProviderKey,v1.0' Version='1.0.0-foo.55' DisplayName='BurnBundle' Imported='yes' />" + |
| 220 | "<RelatedBundle Id='{B94478B1-E1F3-4700-9CE8-6AA090854AEC}' Action='Upgrade' />" + |
| 221 | "<PayloadRef Id='chain.exe' />" + |
| 222 | "</BundlePackage>", |
| 223 | }, bundlePackages); |
| 224 | |
| 225 | var registrations = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); |
| 226 | WixAssert.CompareLineByLine(new[] |
| 227 | { |
| 228 | $"<Registration Id='{parentBundleId}' ExecutableName='parent.exe' PerMachine='yes' Tag='' Version='1.0.1.0' ProviderKey='{parentBundleId}'>" + |
| 229 | "<Arp DisplayName='RemoteBundlePackageBundle' DisplayVersion='1.0.1.0' Publisher='Example Corporation' />" + |
| 230 | "</Registration>" |
| 231 | }, registrations); |
| 232 | |
| 233 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 234 | { |
| 235 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize" } }, |
| 236 | }; |
| 237 | var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 238 | WixAssert.CompareLineByLine(new[] |
| 239 | { |
| 240 | "<WixPackageProperties Package='chain.exe' Vital='yes' DisplayName='BurnBundle' Description='BurnBundleDescription' DownloadSize='*' PackageSize='*' InstalledSize='34' PackageType='Bundle' Permanent='yes' LogPathVariable='WixBundleLog_chain.exe' RollbackLogPathVariable='WixBundleRollbackLog_chain.exe' Compressed='no' Version='1.0.0-foo.55' Cache='keep' />", |
| 241 | }, packageElements); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | [Fact] |
| 246 | public void CanBuildBundleWithV3BundlePackage() |
| 247 | { |
| 248 | var folder = TestData.Get(@"TestData"); |
| 249 | |
| 250 | using (var fs = new DisposableFileSystem()) |
| 251 | { |
| 252 | var baseFolder = fs.GetFolder(); |
| 253 | var dotDataPath = Path.Combine(folder, ".Data"); |
| 254 | var parentIntermediateFolder = Path.Combine(baseFolder, "obj", "Parent"); |
| 255 | var binFolder = Path.Combine(baseFolder, "bin"); |
| 256 | var parentBundlePath = Path.Combine(binFolder, "parent.exe"); |
| 257 | var parentPdbPath = Path.Combine(binFolder, "parent.wixpdb"); |
| 258 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 259 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 260 | string chainBundleId = "{215A70DB-AB35-48C7-BE51-D66EAAC87177}"; |
| 261 | |
| 262 | var result = WixRunner.Execute(false, new[] |
| 263 | { |
| 264 | "build", |
| 265 | Path.Combine(folder, "BundlePackage", "V3BundlePackage.wxs"), |
| 266 | "-bindpath", dotDataPath, |
| 267 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
| 268 | "-intermediateFolder", parentIntermediateFolder, |
| 269 | "-o", parentBundlePath, |
| 270 | }); |
| 271 | |
| 272 | result.AssertSuccess(); |
| 273 | |
| 274 | var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning) |
| 275 | .Select(m => m.ToString().Replace(dotDataPath, "<dotDataPath>")) |
| 276 | .ToArray(); |
| 277 | WixAssert.CompareLineByLine(new[] |
| 278 | { |
| 279 | "The BundlePackage 'v3bundle.exe' does not support hiding its ARP registration.", |
| 280 | }, warningMessages); |
| 281 | |
| 282 | Assert.True(File.Exists(parentBundlePath)); |
| 283 | |
| 284 | var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); |
| 285 | |
| 286 | var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, baFolderPath, extractFolderPath); |
| 287 | extractResult.AssertSuccess(); |
| 288 | |
| 289 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 290 | { |
| 291 | { "BundlePackage", new List<string> { "Size" } }, |
| 292 | }; |
| 293 | var bundlePackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:BundlePackage", ignoreAttributesByElementName); |
| 294 | WixAssert.CompareLineByLine(new[] |
| 295 | { |
| 296 | $"<BundlePackage Id='v3bundle.exe' Cache='keep' CacheId='{chainBundleId}v1.0.0.0' InstallSize='1135' Size='*' PerMachine='yes' Permanent='no' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_v3bundle.exe' RollbackLogPathVariable='WixBundleRollbackLog_v3bundle.exe' RepairCondition='0' BundleId='{chainBundleId}' Version='1.0.0.0' InstallArguments='' UninstallArguments='' RepairArguments='' SupportsBurnProtocol='yes' Win64='no'>" + |
| 297 | "<Provides Key='{215a70db-ab35-48c7-be51-d66eaac87177}' Version='1.0.0.0' DisplayName='CustomV3Theme' Imported='yes' />" + |
| 298 | "<RelatedBundle Id='{2BF4C01F-C132-4E70-97AB-2BC68C7CCD10}' Action='Upgrade' />" + |
| 299 | "<PayloadRef Id='v3bundle.exe' />" + |
| 300 | "</BundlePackage>", |
| 301 | }, bundlePackages); |
| 302 | |
| 303 | var registrations = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); |
| 304 | WixAssert.CompareLineByLine(new[] |
| 305 | { |
| 306 | $"<Registration Id='{parentBundleId}' ExecutableName='parent.exe' PerMachine='yes' Tag='' Version='1.1.1.1' ProviderKey='{parentBundleId}'>" + |
| 307 | "<Arp DisplayName='V3BundlePackageBundle' DisplayVersion='1.1.1.1' Publisher='Example Corporation' />" + |
| 308 | "</Registration>" |
| 309 | }, registrations); |
| 310 | |
| 311 | ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 312 | { |
| 313 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize" } }, |
| 314 | }; |
| 315 | var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 316 | WixAssert.CompareLineByLine(new[] |
| 317 | { |
| 318 | "<WixPackageProperties Package='v3bundle.exe' Vital='yes' DisplayName='CustomV3Theme' Description='CustomV3Theme' DownloadSize='*' PackageSize='*' InstalledSize='1135' PackageType='Bundle' Permanent='no' LogPathVariable='WixBundleLog_v3bundle.exe' RollbackLogPathVariable='WixBundleRollbackLog_v3bundle.exe' Compressed='yes' Version='1.0.0.0' RepairCondition='0' Cache='keep' />", |
| 319 | }, packageElements); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | [Fact] |
| 324 | public void CanBuildBundleWithAllUsersPackage() |
| 325 | { |
| 326 | var folder = TestData.Get("TestData"); |
| 327 | |
| 328 | using (var fs = new DisposableFileSystem()) |
| 329 | { |
| 330 | var baseFolder = fs.GetFolder(); |
| 331 | var dataPath = Path.Combine(folder, ".Data"); |
| 332 | |
| 333 | var msiIntermediateFolder = Path.Combine(baseFolder, "obj", "msi"); |
| 334 | var msiBinFolder = Path.Combine(baseFolder, "bin", "msi"); |
| 335 | var msiPath = Path.Combine(msiBinFolder, "test.msi"); |
| 336 | |
| 337 | var bundleIntermediateFolder = Path.Combine(baseFolder, "obj", "bundle"); |
| 338 | var bundleBinFolder = Path.Combine(baseFolder, "bin", "bundle"); |
| 339 | var bundlePath = Path.Combine(bundleBinFolder, "bundle.exe"); |
| 340 | var bundlePdbPath = Path.Combine(bundleBinFolder, "bundle.wixpdb"); |
| 341 | |
| 342 | var baFolderPath = Path.Combine(baseFolder, "extract", "ba"); |
| 343 | var extractFolderPath = Path.Combine(baseFolder, "extract", "files"); |
| 344 | |
| 345 | var result = WixRunner.Execute(new[] |
| 346 | { |
| 347 | "build", |
| 348 | Path.Combine(folder, "BundleAllUsers", "AllUsersPackage.wxs"), |
| 349 | "-bindpath", dataPath, |
| 350 | "-intermediateFolder", msiIntermediateFolder, |
| 351 | "-o", msiPath |
| 352 | }); |
| 353 | |
| 354 | result.AssertSuccess(); |
| 355 | |
| 356 | result = WixRunner.Execute(new[] |
| 357 | { |
| 358 | "build", |
| 359 | Path.Combine(folder, "BundleAllUsers", "BundleWithAllUsersPackage.wxs"), |
| 360 | "-bindpath", dataPath, |
| 361 | "-bindpath", msiBinFolder, |
| 362 | "-intermediateFolder", bundleIntermediateFolder, |
| 363 | "-o", bundlePath |
| 364 | }); |
| 365 | |
| 366 | result.AssertSuccess(); |
| 367 | |
| 368 | var parentBundleId = GetBundleIdFromWixpdb(bundlePdbPath); |
| 369 | |
| 370 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); |
| 371 | extractResult.AssertSuccess(); |
| 372 | |
| 373 | var registrations = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); |
| 374 | WixAssert.CompareLineByLine(new[] |
| 375 | { |
| 376 | $"<Registration Id='{parentBundleId}' ExecutableName='bundle.exe' PerMachine='yes' Tag='' Version='9.9' ProviderKey='{parentBundleId}'>" + |
| 377 | "<Arp DisplayName='All Users Bundle' DisplayVersion='9.9' Publisher='Example Corporation' />" + |
| 378 | "</Registration>" |
| 379 | }, registrations); |
| 380 | |
| 381 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> |
| 382 | { |
| 383 | { "WixPackageProperties", new List<string> { "DownloadSize", "PackageSize" } }, |
| 384 | }; |
| 385 | |
| 386 | var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); |
| 387 | WixAssert.CompareLineByLine(new[] |
| 388 | { |
| 389 | "<WixPackageProperties Package='test.msi' Vital='yes' DisplayName='All Users Package' DownloadSize='*' PackageSize='*' InstalledSize='28' PackageType='Msi' Permanent='no' LogPathVariable='WixBundleLog_test.msi' RollbackLogPathVariable='WixBundleRollbackLog_test.msi' Compressed='no' ProductCode='{33333333-3333-3333-3333-333333333333}' UpgradeCode='{4BE34BEE-CA23-488E-96A0-B15878E3654B}' Version='1.0' Cache='keep' />", |
| 390 | }, packageElements); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | private static string GetBundleIdFromWixpdb(string bundlePdbPath) |
| 395 | { |
| 396 | using (var wixOutput = WixOutput.Read(bundlePdbPath)) |
| 397 | { |
| 398 | |
| 399 | var intermediate = Intermediate.Load(wixOutput); |
| 400 | var section = intermediate.Sections.Single(); |
| 401 | |
| 402 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); |
| 403 | return bundleSymbol.BundleId; |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | } |