/// <summary> /// Loads json form of intermedaite from stream. /// </summary> /// <param name="stream">Stream to intermediate file.</param> /// <param name="baseUri">Path name of intermediate file.</param> /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param> /// <returns>Returns the loaded json.</returns> private static JsonObject LoadJson(Stream stream, Uri baseUri, bool suppressVersionCheck) { JsonObject jsonObject; using (var fs = FileStructure.Read(stream)) { if (FileFormat.WixIR != fs.FileFormat) { throw new WixUnexpectedFileFormatException(baseUri.LocalPath, FileFormat.WixIR, fs.FileFormat); } var json = fs.GetData(); jsonObject = SimpleJson.DeserializeObject(json) as JsonObject; } if (!suppressVersionCheck) { var versionJson = jsonObject.GetValueOrDefault <string>("version"); if (!Version.TryParse(versionJson, out var version) || !Intermediate.CurrentVersion.Equals(version)) { throw new WixException(ErrorMessages.VersionMismatch(SourceLineNumber.CreateFromUri(baseUri.AbsoluteUri), "intermediate", versionJson, Intermediate.CurrentVersion.ToString())); } } return(jsonObject); }
/// <summary> /// Loads a pdb from a path on disk. /// </summary> /// <param name="path">Path to pdb file saved on disk.</param> /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param> /// <returns>Pdb pdb.</returns> public static Pdb Load(string path, bool suppressVersionCheck) { using (FileStream stream = File.OpenRead(path)) using (FileStructure fs = FileStructure.Read(stream)) { if (FileFormat.Wixpdb != fs.FileFormat) { throw new WixUnexpectedFileFormatException(path, FileFormat.Wixpdb, fs.FileFormat); } Uri uri = new Uri(Path.GetFullPath(path)); using (XmlReader reader = XmlReader.Create(fs.GetDataStream(), null, uri.AbsoluteUri)) { try { reader.MoveToContent(); return(Pdb.Read(reader, suppressVersionCheck)); } catch (XmlException xe) { throw new WixCorruptFileException(path, fs.FileFormat, xe); } } } }
/// <summary> /// Loads a library from a stream. /// </summary> /// <param name="stream">Stream containing the library file.</param> /// <param name="uri">Uri for finding this stream.</param> /// <param name="tableDefinitions">Collection containing TableDefinitions to use when reconstituting the intermediates.</param> /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param> /// <returns>Returns the loaded library.</returns> public static Library Load(Stream stream, Uri uri, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck) { using (FileStructure fs = FileStructure.Read(stream)) { if (FileFormat.Wixlib != fs.FileFormat) { throw new WixUnexpectedFileFormatException(uri.LocalPath, FileFormat.Wixlib, fs.FileFormat); } using (XmlReader reader = XmlReader.Create(fs.GetDataStream(), null, uri.AbsoluteUri)) { try { reader.MoveToContent(); return(Library.Read(reader, tableDefinitions, suppressVersionCheck)); } catch (XmlException xe) { throw new WixCorruptFileException(uri.LocalPath, fs.FileFormat, xe); } } } }