aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.TestPackage/BundleExtractor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.TestPackage/BundleExtractor.cs')
-rw-r--r--src/WixToolset.Core.TestPackage/BundleExtractor.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/WixToolset.Core.TestPackage/BundleExtractor.cs b/src/WixToolset.Core.TestPackage/BundleExtractor.cs
new file mode 100644
index 00000000..3d7b2932
--- /dev/null
+++ b/src/WixToolset.Core.TestPackage/BundleExtractor.cs
@@ -0,0 +1,44 @@
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
3namespace WixToolset.Core.TestPackage
4{
5 using System.IO;
6 using System.Xml;
7 using WixToolset.Core.Burn.Bundles;
8 using WixToolset.Extensibility.Services;
9
10 public class BundleExtractor
11 {
12 public static ExtractBAContainerResult ExtractBAContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath)
13 {
14 var result = new ExtractBAContainerResult();
15 Directory.CreateDirectory(tempFolderPath);
16 using (var burnReader = BurnReader.Open(messaging, bundleFilePath))
17 {
18 result.Success = burnReader.ExtractUXContainer(destinationFolderPath, tempFolderPath);
19 }
20
21 if (result.Success)
22 {
23 result.ManifestDocument = LoadBurnManifest(destinationFolderPath);
24 result.ManifestNamespaceManager = GetBurnNamespaceManager(result.ManifestDocument, "burn");
25 }
26
27 return result;
28 }
29
30 public static XmlNamespaceManager GetBurnNamespaceManager(XmlDocument document, string prefix)
31 {
32 var namespaceManager = new XmlNamespaceManager(document.NameTable);
33 namespaceManager.AddNamespace(prefix, BurnCommon.BurnNamespace);
34 return namespaceManager;
35 }
36
37 public static XmlDocument LoadBurnManifest(string baFolderPath)
38 {
39 var document = new XmlDocument();
40 document.Load(Path.Combine(baFolderPath, "manifest.xml"));
41 return document;
42 }
43 }
44}