From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- .../Unbind/UnbindMsiOrMsmCommand.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs (limited to 'src/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs new file mode 100644 index 00000000..f04dcefe --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs @@ -0,0 +1,53 @@ +// 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.WindowsInstaller.Unbind +{ + using System; + using System.ComponentModel; + using WixToolset.Core.Native; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Msi; + + internal class UnbindMsiOrMsmCommand + { + public UnbindMsiOrMsmCommand(IUnbindContext context) + { + this.Context = context; + } + + public IUnbindContext Context { get; } + + public Output Execute() + { + Output output; + + try + { + using (Database database = new Database(this.Context.InputFilePath, OpenDatabase.ReadOnly)) + { + var unbindCommand = new UnbindDatabaseCommand(this.Context.Messaging, database, this.Context.InputFilePath, OutputType.Product, this.Context.ExportBasePath, this.Context.IntermediateFolder, this.Context.IsAdminImage, this.Context.SuppressDemodularization, skipSummaryInfo: false); + output = unbindCommand.Execute(); + + // extract the files from the cabinets + if (!String.IsNullOrEmpty(this.Context.ExportBasePath) && !this.Context.SuppressExtractCabinets) + { + var extractCommand = new ExtractCabinetsCommand(output, database, this.Context.InputFilePath, this.Context.ExportBasePath, this.Context.IntermediateFolder); + extractCommand.Execute(); + } + } + } + catch (Win32Exception e) + { + if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED + { + throw new WixException(WixErrors.OpenDatabaseFailed(this.Context.InputFilePath)); + } + + throw; + } + + return output; + } + } +} -- cgit v1.2.3-55-g6feb