/// <summary> /// Rebuild the Wixlib using the original Wixlib and updated files. /// </summary> private void RebuildWixlib() { Librarian librarian = new Librarian(); WixVariableResolver wixVariableResolver = new WixVariableResolver(); BlastBinderFileManager binderFileManager = new BlastBinderFileManager(this.outputFile); if (0 == Retina.GetCabinetFileIdToFileNameMap(this.outputFile).Count) { this.messageHandler.Display(this, WixWarnings.NotABinaryWixlib(this.outputFile)); return; } Library library = Library.Load(this.outputFile, librarian.TableDefinitions, false, false); library.Save(this.outputFile, binderFileManager, wixVariableResolver); }
/// <summary> /// Rebuild the Wixlib using the original Wixlib and updated files. /// </summary> private void RebuildWixlib() { if (0 == Retina.GetCabinetFileIdToFileNameMap(this.outputFile).Count) { Messaging.Instance.OnMessage(WixWarnings.NotABinaryWixlib(this.outputFile)); return; } Librarian librarian = new Librarian(); Library library = Library.Load(this.outputFile, librarian.TableDefinitions, false, false); LibraryBinaryFileResolver resolver = new LibraryBinaryFileResolver() { FileManager = new BlastBinderFileManager(this.outputFile) }; library.Save(this.outputFile, resolver); }
/// <summary> /// Extracts files from a binary Wixlib. /// </summary> public void ExtractBinaryWixlibFiles() { Dictionary <string, string> mapCabinetFileIdToFileName = Retina.GetCabinetFileIdToFileNameMap(this.inputFile); if (0 == mapCabinetFileIdToFileName.Count) { Messaging.Instance.OnMessage(WixWarnings.NotABinaryWixlib(this.inputFile)); return; } // extract the files using their cabinet names ("0", "1", etc.) using (WixExtractCab extractor = new WixExtractCab()) { extractor.Extract(this.inputFile, Path.GetDirectoryName(this.inputFile)); } // the same file can be authored multiple times in the same Wixlib Dictionary <string, bool> uniqueFiles = new Dictionary <string, bool>(); // rename those files to what was authored foreach (KeyValuePair <string, string> kvp in mapCabinetFileIdToFileName) { string cabinetFileId = Path.Combine(Path.GetDirectoryName(this.inputFile), kvp.Key); string fileName = Path.Combine(Path.GetDirectoryName(this.inputFile), kvp.Value); uniqueFiles[fileName] = true; Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(this.inputFile), Path.GetDirectoryName(fileName))); if (File.Exists(fileName)) { File.Delete(fileName); } File.Move(cabinetFileId, fileName); } foreach (string fileName in uniqueFiles.Keys) { Console.WriteLine(fileName); } }