/// <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) { Microsoft.Tools.WindowsInstallerXml.Binder binder = new Microsoft.Tools.WindowsInstallerXml.Binder(); 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 pyroAssembly = Assembly.GetExecutingAssembly(); Console.WriteLine("Microsoft (R) Windows Installer Xml Patch Builder Version {0}", pyroAssembly.GetName().Version.ToString()); Console.WriteLine("Copyright (C) Microsoft Corporation 2003. All rights reserved.\n"); Console.WriteLine(); } if (this.showHelp) { Console.WriteLine(" usage: pyro.exe [-?] [-nologo] inputFile -out outputFile [-t baseline wixTransform]"); Console.WriteLine(); Console.WriteLine(" -cc path to cache built cabinets"); Console.WriteLine(" -ext extension assembly or \"class, assembly\""); Console.WriteLine(" -nologo skip printing logo information"); Console.WriteLine(" -notidy do not delete temporary files (useful for debugging)"); Console.WriteLine(" -out specify output file"); Console.WriteLine(" -reusecab reuse cabinets from cabinet cache"); Console.WriteLine(" -sa suppress assemblies: do not get assembly name information for assemblies"); Console.WriteLine(" -sf suppress files: do not get any file information (equivalent to -sa and -sh)"); Console.WriteLine(" -sh suppress file info: do not get hash, version, language, etc"); Console.WriteLine(" -sw<N> suppress warning with specific message ID"); Console.WriteLine(" -t baseline transform one or more wix transforms and its baseline"); Console.WriteLine(" -v verbose output"); Console.WriteLine(" -wx treat warnings as errors"); 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); } // Load the extension if one was passed on the command line. WixExtension wixExtension = null; if (null != this.extension) { wixExtension = WixExtension.Load(extension); } // Load in transforms ArrayList transforms = new ArrayList(); foreach (DictionaryEntry inputTransform in inputTransforms) { Output transformOutput = Output.Load(inputTransform.Key.ToString(), false, false); PatchTransform patchTransform = new PatchTransform(transformOutput, (string)inputTransform.Value); transforms.Add(patchTransform); } // Load the patch Patch patch = new Patch(); patch.Load(this.inputFile); // Copy transforms into output if (0 < transforms.Count) { patch.AttachTransforms(transforms); } // Create and configure the binder binder = new Microsoft.Tools.WindowsInstallerXml.Binder(); binder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); binder.WixVariableResolver = this.wixVariableResolver; binder.Message += new MessageEventHandler(this.messageHandler.Display); binder.SuppressAssemblies = this.suppressAssemblies; binder.SuppressFileHashAndInfo = this.suppressFileHashAndInfo; if (this.suppressFiles) { binder.SuppressAssemblies = true; binder.SuppressFileHashAndInfo = true; } // Load the extension if provided and set all its properties if (null != wixExtension) { binder.Extension = wixExtension.BinderExtension; } if (null != this.cabCachePath || this.reuseCabinets) { // ensure the cabinet cache path exists if we are going to use it if (null != this.cabCachePath && !Directory.Exists(this.cabCachePath)) { Directory.CreateDirectory(this.cabCachePath); } } binder.Extension.ReuseCabinets = this.reuseCabinets; binder.Extension.CabCachePath = this.cabCachePath; binder.Extension.Output = patch.PatchOutput; // Bind the patch to an msp. binder.Bind(patch.PatchOutput, this.outputFile); } catch (WixException we) { this.OnMessage(we.Error); } catch (Exception e) { this.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); if (e is NullReferenceException || e is SEHException) { throw; } } finally { if (null != binder) { if (this.tidy) { if (!binder.DeleteTempFiles()) { Console.WriteLine("Warning, failed to delete temporary directory: {0}", binder.TempFilesLocation); } } else { Console.WriteLine("Temporary directory located at '{0}'.", binder.TempFilesLocation); } } } return(this.messageHandler.LastErrorNumber); }
/// <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) { 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) { AppCommon.DisplayToolHeader(); } if (this.showHelp) { Console.WriteLine(PyroStrings.HelpMessage); AppCommon.DisplayToolFooter(); return this.messageHandler.LastErrorNumber; } // Load in transforms ArrayList transforms = new ArrayList(); foreach (string inputTransform in inputTransformsOrdered) { PatchTransform patchTransform = new PatchTransform(inputTransform, inputTransforms[inputTransform]); patchTransform.Message += new MessageEventHandler(this.messageHandler.Display); transforms.Add(patchTransform); } // Create and configure the patch Patch patch = new Patch(); patch.Message += new MessageEventHandler(this.messageHandler.Display); // Create and configure the binder binder = new Microsoft.Tools.WindowsInstallerXml.Binder(); binder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); binder.WixVariableResolver = this.wixVariableResolver; binder.Message += new MessageEventHandler(this.messageHandler.Display); binder.SuppressAssemblies = this.suppressAssemblies; binder.SuppressFileHashAndInfo = this.suppressFileHashAndInfo; binder.SetMsiAssemblyNameFileVersion = this.setAssemblyFileVersions; // have the binder parse the command line arguments light did not recognize string[] unparsedArgsArray = new string[this.unparsedArgs.Count]; this.unparsedArgs.CopyTo(unparsedArgsArray, 0); StringCollection remainingArgs = this.binder.ParseCommandLine(unparsedArgsArray, this.messageHandler); // Load the extensions bool binderFileManagerLoaded = false; foreach (String extension in this.extensions) { WixExtension wixExtension = WixExtension.Load(extension); binder.AddExtension(wixExtension); patch.AddExtension(wixExtension); if (0 < remainingArgs.Count) { remainingArgs = wixExtension.ParseCommandLine(remainingArgs, this.messageHandler); } if (null != wixExtension.BinderFileManager) { if (binderFileManagerLoaded) { throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, PyroStrings.EXP_CannotLoadBinderFileManager, wixExtension.BinderFileManager.GetType().ToString(), binder.FileManager.ToString()), "ext"); } binder.FileManager = wixExtension.BinderFileManager; binderFileManagerLoaded = true; } } foreach (string parameter in remainingArgs) { this.messageHandler.Display(this, WixWarnings.UnsupportedCommandLineArgument(parameter)); } if (this.messageHandler.EncounteredError) { return this.messageHandler.LastErrorNumber; } // since the binder is now ready, let's plug dynamic bindpath into file manager this.PrepareDataForFileManager(); // Load the patch patch.Load(this.inputFile); // Copy transforms into output if (0 < transforms.Count) { patch.AttachTransforms(transforms); } if (this.messageHandler.EncounteredError) { return this.messageHandler.LastErrorNumber; } if (null == this.pdbFile && null != this.outputFile) { this.pdbFile = Path.ChangeExtension(this.outputFile, ".wixpdb"); } binder.PdbFile = suppressWixPdb ? null : this.pdbFile; if (this.suppressFiles) { binder.SuppressAssemblies = true; binder.SuppressFileHashAndInfo = true; } if (null != this.cabCachePath || this.reuseCabinets) { // ensure the cabinet cache path exists if we are going to use it if (null != this.cabCachePath && !Directory.Exists(this.cabCachePath)) { Directory.CreateDirectory(this.cabCachePath); } } binder.AllowEmptyTransforms = this.allowEmptyTransforms; binder.FileManager.ReuseCabinets = this.reuseCabinets; binder.FileManager.CabCachePath = this.cabCachePath; binder.FileManager.Output = patch.PatchOutput; binder.FileManager.DeltaBinaryPatch = this.delta; // Bind the patch to an msp. binder.Bind(patch.PatchOutput, this.outputFile); } catch (WixException we) { this.OnMessage(we.Error); } catch (Exception e) { this.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); if (e is NullReferenceException || e is SEHException) { throw; } } finally { if (null != binder) { if (this.tidy) { if (!binder.DeleteTempFiles()) { Console.WriteLine(PyroStrings.WAR_FailedToDeleteTempDir, binder.TempFilesLocation); } } else { Console.WriteLine(PyroStrings.INF_TempDirLocatedAt, binder.TempFilesLocation); } } } return this.messageHandler.LastErrorNumber; }
/// <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) { 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) { AppCommon.DisplayToolHeader(); } if (this.showHelp) { Console.WriteLine(PyroStrings.HelpMessage); AppCommon.DisplayToolFooter(); return(this.messageHandler.LastErrorNumber); } // Load in transforms ArrayList transforms = new ArrayList(); foreach (string inputTransform in inputTransformsOrdered) { PatchTransform patchTransform = new PatchTransform(inputTransform, inputTransforms[inputTransform]); patchTransform.Message += new MessageEventHandler(this.messageHandler.Display); transforms.Add(patchTransform); } // Create and configure the patch Patch patch = new Patch(); patch.Message += new MessageEventHandler(this.messageHandler.Display); // Create and configure the binder binder = new Microsoft.Tools.WindowsInstallerXml.Binder(); binder.TempFilesLocation = Environment.GetEnvironmentVariable("WIX_TEMP"); binder.WixVariableResolver = this.wixVariableResolver; binder.Message += new MessageEventHandler(this.messageHandler.Display); binder.SuppressAssemblies = this.suppressAssemblies; binder.SuppressFileHashAndInfo = this.suppressFileHashAndInfo; binder.SetMsiAssemblyNameFileVersion = this.setAssemblyFileVersions; // have the binder parse the command line arguments light did not recognize string[] unparsedArgsArray = new string[this.unparsedArgs.Count]; this.unparsedArgs.CopyTo(unparsedArgsArray, 0); StringCollection remainingArgs = this.binder.ParseCommandLine(unparsedArgsArray, this.messageHandler); // Load the extensions bool binderFileManagerLoaded = false; foreach (String extension in this.extensions) { WixExtension wixExtension = WixExtension.Load(extension); binder.AddExtension(wixExtension); patch.AddExtension(wixExtension); if (0 < remainingArgs.Count) { remainingArgs = wixExtension.ParseCommandLine(remainingArgs, this.messageHandler); } if (null != wixExtension.BinderFileManager) { if (binderFileManagerLoaded) { throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, PyroStrings.EXP_CannotLoadBinderFileManager, wixExtension.BinderFileManager.GetType().ToString(), binder.FileManager.ToString()), "ext"); } binder.FileManager = wixExtension.BinderFileManager; binderFileManagerLoaded = true; } } foreach (string parameter in remainingArgs) { this.messageHandler.Display(this, WixWarnings.UnsupportedCommandLineArgument(parameter)); } if (this.messageHandler.EncounteredError) { return(this.messageHandler.LastErrorNumber); } // since the binder is now ready, let's plug dynamic bindpath into file manager this.PrepareDataForFileManager(); // Load the patch patch.Load(this.inputFile); // Copy transforms into output if (0 < transforms.Count) { patch.AttachTransforms(transforms); } if (this.messageHandler.EncounteredError) { return(this.messageHandler.LastErrorNumber); } if (null == this.pdbFile && null != this.outputFile) { this.pdbFile = Path.ChangeExtension(this.outputFile, ".wixpdb"); } binder.PdbFile = suppressWixPdb ? null : this.pdbFile; if (this.suppressFiles) { binder.SuppressAssemblies = true; binder.SuppressFileHashAndInfo = true; } if (null != this.cabCachePath || this.reuseCabinets) { // ensure the cabinet cache path exists if we are going to use it if (null != this.cabCachePath && !Directory.Exists(this.cabCachePath)) { Directory.CreateDirectory(this.cabCachePath); } } binder.AllowEmptyTransforms = this.allowEmptyTransforms; binder.FileManager.ReuseCabinets = this.reuseCabinets; binder.FileManager.CabCachePath = this.cabCachePath; binder.FileManager.Output = patch.PatchOutput; binder.FileManager.DeltaBinaryPatch = this.delta; // Bind the patch to an msp. binder.Bind(patch.PatchOutput, this.outputFile); } catch (WixException we) { this.OnMessage(we.Error); } catch (Exception e) { this.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); if (e is NullReferenceException || e is SEHException) { throw; } } finally { if (null != binder) { if (this.tidy) { if (!binder.DeleteTempFiles()) { Console.WriteLine(PyroStrings.WAR_FailedToDeleteTempDir, binder.TempFilesLocation); } } else { Console.WriteLine(PyroStrings.INF_TempDirLocatedAt, binder.TempFilesLocation); } } } return(this.messageHandler.LastErrorNumber); }
/// <summary> /// Main running method for the application. /// </summary> private void Run() { WixVariableResolver wixVariableResolver = new WixVariableResolver(); // Initialize the binder from the command line. WixToolset.Binder binder = new WixToolset.Binder(); binder.CabCachePath = this.commandLine.CabCachePath; //binder.DeltaBinaryPatch = this.commandLine.Delta; //binder.ContentsFile = this.commandLine.ContentsFile; //binder.BuiltOutputsFile = this.commandLine.BuiltOutputsFile; //binder.OutputsFile = this.commandLine.OutputsFile; //binder.WixprojectFile = this.commandLine.WixprojectFile; //binder.BindPaths.AddRange(this.commandLine.BindPaths); binder.TargetBindPaths.AddRange(this.commandLine.TargetBindPaths); binder.UpdatedBindPaths.AddRange(this.commandLine.UpdatedBindPaths); //binder.CabbingThreadCount = this.commandLine.CabbingThreadCount; //binder.DefaultCompressionLevel = this.commandLine.DefaultCompressionLevel; //binder.ExactAssemblyVersions = this.commandLine.ExactAssemblyVersions; binder.SuppressAclReset = this.commandLine.SuppressAclReset; //binder.SuppressLayout = this.commandLine.SuppressLayout; binder.SuppressValidation = true; binder.PdbFile = this.commandLine.SuppressWixPdb ? null : this.commandLine.PdbFile; binder.TempFilesLocation = AppCommon.GetTempLocation(); binder.WixVariableResolver = wixVariableResolver; foreach (IBinderExtension extension in this.binderExtensions) { binder.AddExtension(extension); } foreach (IBinderFileManager fileManager in this.fileManagers) { binder.AddExtension(fileManager); } // Create and configure the patch Patch patch = new Patch(); patch.Load(this.commandLine.InputFile); patch.AttachTransforms(this.commandLine.PatchTransforms); bool tidy = true; // clean up after ourselves by default. try { // Bind the patch to an msp. binder.Bind(patch.PatchOutput, this.commandLine.OutputFile); } catch (WixException we) { if (we is WixInvalidIdtException) { tidy = false; } throw; } catch (Exception) { tidy = false; throw; } finally { if (null != binder) { binder.Cleanup(tidy); } } return; }