/// <summary> /// Extracts files from a merge module and creates corresponding ComponentGroup WiX authoring. /// </summary> private void MeltModule() { Decompiler decompiler = null; Unbinder unbinder = null; Melter melter = null; try { // create the decompiler, unbinder, and melter decompiler = new Decompiler(); unbinder = new Unbinder(); melter = new Melter(decompiler, id); // read the configuration file (melt.exe.config) AppCommon.ReadConfiguration(this.extensionList); // load any extensions foreach (string extension in this.extensionList) { WixExtension wixExtension = WixExtension.Load(extension); decompiler.AddExtension(wixExtension); unbinder.AddExtension(wixExtension); } // set options decompiler.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.SuppressDemodularization = true; decompiler.Message += new MessageEventHandler(this.messageHandler.Display); unbinder.Message += new MessageEventHandler(this.messageHandler.Display); melter.Message += new MessageEventHandler(this.messageHandler.Display); // print friendly message saying what file is being decompiled Console.WriteLine(Path.GetFileName(this.inputFile)); // unbind Output output = unbinder.Unbind(this.inputFile, this.outputType, this.exportBasePath); if (null != output) { Wix.Wix wix = melter.Melt(output); if (null != wix) { XmlTextWriter writer = null; try { writer = new XmlTextWriter(this.outputFile, System.Text.Encoding.UTF8); writer.Indentation = 4; writer.IndentChar = ' '; writer.QuoteChar = '"'; writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); wix.OutputXml(writer); writer.WriteEndDocument(); } finally { if (null != writer) { writer.Close(); } } } } } finally { if (null != decompiler) { if (this.tidy) { if (!decompiler.DeleteTempFiles()) { Console.WriteLine(MeltStrings.WAR_FailedToDeleteTempDir, decompiler.TempFilesLocation); } } else { Console.WriteLine(MeltStrings.INF_TempDirLocatedAt, decompiler.TempFilesLocation); } } if (null != unbinder) { if (this.tidy) { if (!unbinder.DeleteTempFiles()) { Console.WriteLine(MeltStrings.WAR_FailedToDeleteTempDir, unbinder.TempFilesLocation); } } else { Console.WriteLine(MeltStrings.INF_TempDirLocatedAt, unbinder.TempFilesLocation); } } } }
/// <summary> /// Extracts files from a merge module and creates corresponding ComponentGroup WiX authoring. /// </summary> private void MeltModule() { Decompiler decompiler = null; Unbinder unbinder = null; Melter melter = null; try { // create the decompiler, unbinder, and melter decompiler = new Decompiler(); unbinder = new Unbinder(); melter = new Melter(decompiler, id); // read the configuration file (melt.exe.config) AppCommon.ReadConfiguration(this.extensionList); // load all extensions ExtensionManager extensionManager = new ExtensionManager(); foreach (string extension in this.extensionList) { extensionManager.Load(extension); } foreach (IDecompilerExtension extension in extensionManager.Create <IDecompilerExtension>()) { decompiler.AddExtension(extension); } foreach (IUnbinderExtension extension in extensionManager.Create <IUnbinderExtension>()) { unbinder.AddExtension(extension); } // set options decompiler.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.SuppressDemodularization = true; // print friendly message saying what file is being decompiled Console.WriteLine(Path.GetFileName(this.inputFile)); // unbind Output output = unbinder.Unbind(this.inputFile, this.outputType, this.exportBasePath); if (null != output) { Wix.Wix wix = melter.Melt(output); if (null != wix) { XmlTextWriter writer = null; try { writer = new XmlTextWriter(this.outputFile, System.Text.Encoding.UTF8); writer.Indentation = 4; writer.IndentChar = ' '; writer.QuoteChar = '"'; writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); wix.OutputXml(writer); writer.WriteEndDocument(); } finally { if (null != writer) { writer.Close(); } } } } } finally { if (null != decompiler) { if (this.tidy) { if (!decompiler.DeleteTempFiles()) { Console.WriteLine(MeltStrings.WAR_FailedToDeleteTempDir, decompiler.TempFilesLocation); } } else { Console.WriteLine(MeltStrings.INF_TempDirLocatedAt, decompiler.TempFilesLocation); } } if (null != unbinder) { if (this.tidy) { if (!unbinder.DeleteTempFiles()) { Console.WriteLine(MeltStrings.WAR_FailedToDeleteTempDir, unbinder.TempFilesLocation); } } else { Console.WriteLine(MeltStrings.INF_TempDirLocatedAt, unbinder.TempFilesLocation); } } } }
/// <summary> /// Main running method for the application. /// </summary> /// <param name="args">Commandline arguments to the application.</param> /// <returns>Returns the application error code.</returns> private int Run(string[] args) { Decompiler decompiler = null; Unbinder unbinder = null; Melter melter = null; try { // parse the command line this.ParseCommandLine(args); // exit if there was an error parsing the command line (otherwise the logo appears after error messages) if (this.messageHandler.EncounteredError) { return(this.messageHandler.LastErrorNumber); } if (null == this.inputFile || null == this.outputFile) { this.showHelp = true; } if (this.showLogo) { Assembly meltAssembly = Assembly.GetExecutingAssembly(); Console.WriteLine("Microsoft (R) Windows Installer Xml Melter Version {0}", meltAssembly.GetName().Version.ToString()); Console.WriteLine("Copyright (C) Microsoft Corporation 2003. All rights reserved.\n"); Console.WriteLine(); } if (this.showHelp) { Console.WriteLine(" usage: melt.exe [-?] [-nologo] database.msi source.wxs"); Console.WriteLine(); Console.WriteLine(" -ext extension assembly or \"class, assembly\""); Console.WriteLine(" -id friendly identifier to use instead of module id"); Console.WriteLine(" -nologo skip printing melt logo information"); Console.WriteLine(" -notidy do not delete temporary files (useful for debugging)"); Console.WriteLine(" -sw<N> suppress warning with specific message ID"); Console.WriteLine(" -v verbose output"); Console.WriteLine(" -wx treat warnings as errors"); Console.WriteLine(" -x <path> export binaries from msm to this path (defaults to output files path"); Console.WriteLine(" -? this help information"); Console.WriteLine(); Console.WriteLine("Environment variables:"); Console.WriteLine(" WIX_TEMP overrides the temporary directory used for cab extraction, binary extraction, ..."); Console.WriteLine(); Console.WriteLine("Common extensions:"); Console.WriteLine(" .wxi - Windows installer Xml Include file"); Console.WriteLine(" .wxl - Windows installer Xml Localization file"); Console.WriteLine(" .wxs - Windows installer Xml Source file"); Console.WriteLine(" .wixlib - Windows installer Xml Library file (in XML format)"); Console.WriteLine(" .wixobj - Windows installer Xml Object file (in XML format)"); Console.WriteLine(" .wixout - Windows installer Xml Output file (in XML format)"); Console.WriteLine(); Console.WriteLine(" .msi - Windows installer Product Database"); Console.WriteLine(" .msm - Windows installer Merge Module"); Console.WriteLine(" .msp - Windows installer Patch"); Console.WriteLine(" .mst - Windows installer Transform"); Console.WriteLine(" .pcp - Windows installer Patch Creation Package"); Console.WriteLine(); Console.WriteLine("For more information see: http://wix.sourceforge.net"); return(this.messageHandler.LastErrorNumber); } // create the decompiler, unbinder, and melter decompiler = new Decompiler(); unbinder = new Unbinder(); melter = new Melter(decompiler, id); // read the configuration file (melt.exe.config) AppCommon.ReadConfiguration(this.extensionList); // load any extensions foreach (string extension in this.extensionList) { WixExtension wixExtension = WixExtension.Load(extension); decompiler.AddExtension(wixExtension); unbinder.AddExtension(wixExtension); } // set options decompiler.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); unbinder.SuppressDemodularization = true; decompiler.Message += new MessageEventHandler(this.messageHandler.Display); unbinder.Message += new MessageEventHandler(this.messageHandler.Display); melter.Message += new MessageEventHandler(this.messageHandler.Display); if (null == this.exportBasePath) { this.exportBasePath = System.IO.Path.GetDirectoryName(this.outputFile); } // print friendly message saying what file is being decompiled Console.WriteLine(Path.GetFileName(this.inputFile)); // unbind Output output = unbinder.Unbind(this.inputFile, this.outputType, this.exportBasePath); if (null != output) { Wix.Wix wix = melter.Melt(output); if (null != wix) { XmlTextWriter writer = null; try { writer = new XmlTextWriter(this.outputFile, System.Text.Encoding.UTF8); writer.Indentation = 4; writer.IndentChar = ' '; writer.QuoteChar = '"'; writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); wix.OutputXml(writer); writer.WriteEndDocument(); } finally { if (null != writer) { writer.Close(); } } } } } catch (WixException we) { this.messageHandler.Display(this, we.Error); } catch (Exception e) { this.messageHandler.Display(this, WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); if (e is NullReferenceException || e is SEHException) { throw; } } finally { if (null != decompiler) { if (this.tidy) { if (!decompiler.DeleteTempFiles()) { Console.WriteLine("Warning, failed to delete temporary directory: {0}", decompiler.TempFilesLocation); } } else { Console.WriteLine("Temporary directory located at '{0}'.", decompiler.TempFilesLocation); } } if (null != unbinder) { if (this.tidy) { if (!unbinder.DeleteTempFiles()) { Console.WriteLine("Warning, failed to delete temporary directory: {0}", unbinder.TempFilesLocation); } } else { Console.WriteLine("Temporary directory located at '{0}'.", unbinder.TempFilesLocation); } } } return(this.messageHandler.LastErrorNumber); }