/// <summary> /// Closes the underlying file stream. /// </summary> public void Shutdown() { Environment.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", _initialTargetOutputLogging); Environment.SetEnvironmentVariable("MSBUILDLOGIMPORTS", _initialLogImports); if (projectImportsCollector != null) { if (CollectProjectImports == ProjectImportsCollectionMode.Embed) { eventArgsWriter.WriteBlob(BinaryLogRecordKind.ProjectImportArchive, projectImportsCollector.GetAllBytes()); } projectImportsCollector.Close(); projectImportsCollector = null; } if (stream != null) { // It's hard to determine whether we're at the end of decoding GZipStream // so add an explicit 0 at the end to signify end of file stream.WriteByte((byte)BinaryLogRecordKind.EndOfFile); stream.Flush(); stream.Dispose(); stream = null; } }
/// <summary> /// Closes the underlying file stream. /// </summary> public void Shutdown() { Environment.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", _initialTargetOutputLogging); Environment.SetEnvironmentVariable("MSBUILDLOGIMPORTS", _initialLogImports); if (projectImportsCollector != null) { projectImportsCollector.Close(); if (CollectProjectImports == ProjectImportsCollectionMode.Embed) { var archiveFilePath = projectImportsCollector.ArchiveFilePath; // It is possible that the archive couldn't be created for some reason. // Only embed it if it actually exists. if (File.Exists(archiveFilePath)) { eventArgsWriter.WriteBlob(BinaryLogRecordKind.ProjectImportArchive, File.ReadAllBytes(archiveFilePath)); File.Delete(archiveFilePath); } } projectImportsCollector = null; } if (stream != null) { // It's hard to determine whether we're at the end of decoding GZipStream // so add an explicit 0 at the end to signify end of file stream.WriteByte((byte)BinaryLogRecordKind.EndOfFile); stream.Flush(); stream.Dispose(); stream = null; } }
public override void Shutdown() { base.Shutdown(); if (projectImportsCollector != null) { var archiveFilePath = projectImportsCollector.ArchiveFilePath; projectImportsCollector.Close(); projectImportsCollector = null; if (File.Exists(archiveFilePath)) { var bytes = File.ReadAllBytes(archiveFilePath); construction.Build.SourceFilesArchive = bytes; File.Delete(archiveFilePath); } } if (SaveLogToDisk) { try { if (Path.IsPathRooted(_logFile)) { var parentDirectory = Path.GetDirectoryName(_logFile); if (!Directory.Exists(parentDirectory)) { Directory.CreateDirectory(parentDirectory); } } Serialization.Write(construction.Build, _logFile); } catch (Exception ex) { ErrorReporting.ReportException(ex); } } else { CurrentBuild = construction.Build; } }