diff --git a/src/CodeFormatter.cs b/src/CodeFormatter.cs index c687fca9bc..6483d1f5cc 100644 --- a/src/CodeFormatter.cs +++ b/src/CodeFormatter.cs @@ -33,7 +33,8 @@ internal static class CodeFormatter public static async Task FormatWorkspaceAsync( FormatOptions options, ILogger logger, - CancellationToken cancellationToken) + CancellationToken cancellationToken, + bool createBinaryLog = false) { var (workspaceFilePath, workspaceType, logLevel, saveFormattedFiles, _, fileMatcher, reportPath) = options; var logWorkspaceWarnings = logLevel == LogLevel.Trace; @@ -45,7 +46,7 @@ internal static class CodeFormatter var workspaceStopwatch = Stopwatch.StartNew(); using (var workspace = await OpenWorkspaceAsync( - workspaceFilePath, workspaceType, fileMatcher, logWorkspaceWarnings, logger, cancellationToken).ConfigureAwait(false)) + workspaceFilePath, workspaceType, fileMatcher, logWorkspaceWarnings, logger, cancellationToken, createBinaryLog).ConfigureAwait(false)) { if (workspace is null) { @@ -147,7 +148,8 @@ private static string GetReportFilePath(string reportPath) Matcher fileMatcher, bool logWorkspaceWarnings, ILogger logger, - CancellationToken cancellationToken) + CancellationToken cancellationToken, + bool createBinaryLog = false) { if (workspaceType == WorkspaceType.Folder) { @@ -156,7 +158,7 @@ private static string GetReportFilePath(string reportPath) return folderWorkspace; } - return await OpenMSBuildWorkspaceAsync(workspacePath, workspaceType, logWorkspaceWarnings, logger, cancellationToken); + return await OpenMSBuildWorkspaceAsync(workspacePath, workspaceType, logWorkspaceWarnings, logger, cancellationToken, createBinaryLog); } private static async Task OpenMSBuildWorkspaceAsync( @@ -164,7 +166,8 @@ private static string GetReportFilePath(string reportPath) WorkspaceType workspaceType, bool logWorkspaceWarnings, ILogger logger, - CancellationToken cancellationToken) + CancellationToken cancellationToken, + bool createBinaryLog = false) { var properties = new Dictionary(StringComparer.Ordinal) { @@ -178,6 +181,7 @@ private static string GetReportFilePath(string reportPath) }; var workspace = MSBuildWorkspace.Create(properties); + workspace.ProduceBinaryLog = createBinaryLog; if (workspaceType == WorkspaceType.Solution) { diff --git a/src/Program.cs b/src/Program.cs index 037d45891d..5767a72ceb 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -150,7 +150,8 @@ public static async Task Run(string folder, string workspace, string verbos var formatResult = await CodeFormatter.FormatWorkspaceAsync( formatOptions, logger, - cancellationTokenSource.Token).ConfigureAwait(false); + cancellationTokenSource.Token, + createBinaryLog: logLevel == LogLevel.Trace ? true : false).ConfigureAwait(false); return GetExitCode(formatResult, check); }