From afbc6889c73d58136cb8851858ca3c17f41dc2c5 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 26 Mar 2020 15:21:06 +1000 Subject: Add BundleExtension element. Add GetTestXml. Fix issue with building with current version of burn. --- src/WixToolset.Core.TestPackage/BundleExtractor.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/WixToolset.Core.TestPackage/BundleExtractor.cs (limited to 'src/WixToolset.Core.TestPackage/BundleExtractor.cs') 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 @@ +// 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. + +namespace WixToolset.Core.TestPackage +{ + using System.IO; + using System.Xml; + using WixToolset.Core.Burn.Bundles; + using WixToolset.Extensibility.Services; + + public class BundleExtractor + { + public static ExtractBAContainerResult ExtractBAContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath) + { + var result = new ExtractBAContainerResult(); + Directory.CreateDirectory(tempFolderPath); + using (var burnReader = BurnReader.Open(messaging, bundleFilePath)) + { + result.Success = burnReader.ExtractUXContainer(destinationFolderPath, tempFolderPath); + } + + if (result.Success) + { + result.ManifestDocument = LoadBurnManifest(destinationFolderPath); + result.ManifestNamespaceManager = GetBurnNamespaceManager(result.ManifestDocument, "burn"); + } + + return result; + } + + public static XmlNamespaceManager GetBurnNamespaceManager(XmlDocument document, string prefix) + { + var namespaceManager = new XmlNamespaceManager(document.NameTable); + namespaceManager.AddNamespace(prefix, BurnCommon.BurnNamespace); + return namespaceManager; + } + + public static XmlDocument LoadBurnManifest(string baFolderPath) + { + var document = new XmlDocument(); + document.Load(Path.Combine(baFolderPath, "manifest.xml")); + return document; + } + } +} -- cgit v1.2.3-55-g6feb