/// <summary> /// Loads an output from a path on disk. /// </summary> /// <param name="path">Path to output file saved on disk.</param> /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param> /// <returns>Output object.</returns> public static Output Load(string path, bool suppressVersionCheck) { using (FileStream stream = File.OpenRead(path)) using (FileStructure fs = FileStructure.Read(stream)) { if (FileFormat.Wixout != fs.FileFormat) { throw new WixUnexpectedFileFormatException(path, FileFormat.Wixout, fs.FileFormat); } Uri uri = new Uri(Path.GetFullPath(path)); using (XmlReader reader = XmlReader.Create(fs.GetDataStream(), null, uri.AbsoluteUri)) { try { reader.MoveToContent(); return(Output.Read(reader, suppressVersionCheck)); } catch (XmlException xe) { throw new WixCorruptFileException(path, fs.FileFormat, xe); } } } }
public void Execute() { var group = this.FilesWithEmbeddedFiles.GroupBy(e => e.Uri); foreach (var expectedEmbeddedFileByUri in group) { var baseUri = expectedEmbeddedFileByUri.Key; Stream stream = null; try { // If the embedded files are stored in an assembly resource stream (usually // a .wixlib embedded in a WixExtension). if ("embeddedresource" == baseUri.Scheme) { var assemblyPath = Path.GetFullPath(baseUri.LocalPath); var resourceName = baseUri.Fragment.TrimStart('#'); var assembly = Assembly.LoadFile(assemblyPath); stream = assembly.GetManifestResourceStream(resourceName); } else // normal file (usually a binary .wixlib on disk). { stream = File.OpenRead(baseUri.LocalPath); } using (var fs = FileStructure.Read(stream)) { var uniqueIndicies = new SortedSet <int>(); foreach (var embeddedFile in expectedEmbeddedFileByUri) { if (uniqueIndicies.Add(embeddedFile.EmbeddedFileIndex)) { fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); } } } } finally { stream?.Close(); } } }
public void Execute() { foreach (var baseUri in this.FilesWithEmbeddedFiles.Uris) { Stream stream = null; try { // If the embedded files are stored in an assembly resource stream (usually // a .wixlib embedded in a WixExtension). if ("embeddedresource" == baseUri.Scheme) { string assemblyPath = Path.GetFullPath(baseUri.LocalPath); string resourceName = baseUri.Fragment.TrimStart('#'); Assembly assembly = Assembly.LoadFile(assemblyPath); stream = assembly.GetManifestResourceStream(resourceName); } else // normal file (usually a binary .wixlib on disk). { stream = File.OpenRead(baseUri.LocalPath); } using (FileStructure fs = FileStructure.Read(stream)) { foreach (var embeddedFile in this.FilesWithEmbeddedFiles.GetExtractFilesForUri(baseUri)) { fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); } } } finally { if (null != stream) { stream.Close(); } } } }