From 2bb37beda887d120a0ddabf874ad25357101faa1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:59:45 -0700 Subject: Update to WiX Intermediate Representation --- src/WixToolset.Core.WindowsInstaller/Unbinder.cs | 88 ++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/WixToolset.Core.WindowsInstaller/Unbinder.cs (limited to 'src/WixToolset.Core.WindowsInstaller/Unbinder.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Unbinder.cs b/src/WixToolset.Core.WindowsInstaller/Unbinder.cs new file mode 100644 index 00000000..d2d27d45 --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Unbinder.cs @@ -0,0 +1,88 @@ +// 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 +{ + using System.Collections; + using System.IO; + using WixToolset.Data; + using WixToolset.Extensibility; + using System.Collections.Generic; + + /// + /// Unbinder core of the WiX toolset. + /// + public sealed class Unbinder + { + public IEnumerable BackendFactories { get; } + + /// + /// Gets or sets whether the input msi is an admin image. + /// + /// Set to true if the input msi is part of an admin image. + public bool IsAdminImage { get; set; } + + /// + /// Gets or sets the option to suppress demodularizing values. + /// + /// The option to suppress demodularizing values. + public bool SuppressDemodularization { get; set; } + + /// + /// Gets or sets the option to suppress extracting cabinets. + /// + /// The option to suppress extracting cabinets. + public bool SuppressExtractCabinets { get; set; } + + /// + /// Gets or sets the temporary path for the Binder. If left null, the binder + /// will use %TEMP% environment variable. + /// + /// Path to temp files. + public string TempFilesLocation => Path.GetTempPath(); + + /// + /// Unbind a Windows Installer file. + /// + /// The Windows Installer file. + /// The type of output to create. + /// The path where files should be exported. + /// The output representing the database. + public Intermediate Unbind(string file, OutputType outputType, string exportBasePath) + { + if (!File.Exists(file)) + { + if (OutputType.Transform == outputType) + { + throw new WixException(WixErrors.FileNotFound(null, file, "Transform")); + } + else + { + throw new WixException(WixErrors.FileNotFound(null, file, "Database")); + } + } + + // if we don't have the temporary files object yet, get one + Directory.CreateDirectory(this.TempFilesLocation); // ensure the base path is there + + var context = new UnbindContext(); + context.InputFilePath = file; + context.ExportBasePath = exportBasePath; + context.IntermediateFolder = this.TempFilesLocation; + context.IsAdminImage = this.IsAdminImage; + context.SuppressDemodularization = this.SuppressDemodularization; + context.SuppressExtractCabinets = this.SuppressExtractCabinets; + + foreach (var factory in this.BackendFactories) + { + if (factory.TryCreateBackend(outputType.ToString(), file, null, out var backend)) + { + return backend.Unbind(context); + } + } + + // TODO: Display message that could not find a unbinder for output type? + + return null; + } + } +} -- cgit v1.2.3-55-g6feb