From e833443d67c82929d9da8fa94bd0d114f5f1cc6e Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Wed, 1 Apr 2020 07:14:25 -0700 Subject: [PATCH] consume new API --- src/CodeFormatter.cs | 16 +++++++++++++--- src/dotnet-format.csproj | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/CodeFormatter.cs b/src/CodeFormatter.cs index 6483d1f5cc..96b93ec70b 100644 --- a/src/CodeFormatter.cs +++ b/src/CodeFormatter.cs @@ -9,6 +9,7 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Microsoft.Build.Logging; using Microsoft.CodeAnalysis.MSBuild; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Tools.Formatters; @@ -181,17 +182,26 @@ private static string GetReportFilePath(string reportPath) }; var workspace = MSBuildWorkspace.Create(properties); - workspace.ProduceBinaryLog = createBinaryLog; + + Build.Framework.ILogger binlog = null; + if (createBinaryLog) + { + binlog = new BinaryLogger() + { + Parameters = Path.Combine(Environment.CurrentDirectory, "formatDiagnosticLog.binlog"), + Verbosity = Build.Framework.LoggerVerbosity.Diagnostic, + }; + } if (workspaceType == WorkspaceType.Solution) { - await workspace.OpenSolutionAsync(solutionOrProjectPath, cancellationToken: cancellationToken).ConfigureAwait(false); + await workspace.OpenSolutionAsync(solutionOrProjectPath, msbuildLogger: binlog, cancellationToken: cancellationToken).ConfigureAwait(false); } else { try { - await workspace.OpenProjectAsync(solutionOrProjectPath, cancellationToken: cancellationToken).ConfigureAwait(false); + await workspace.OpenProjectAsync(solutionOrProjectPath, msbuildLogger: binlog, cancellationToken: cancellationToken).ConfigureAwait(false); } catch (InvalidOperationException) { diff --git a/src/dotnet-format.csproj b/src/dotnet-format.csproj index 86b4494a74..a61a130efb 100644 --- a/src/dotnet-format.csproj +++ b/src/dotnet-format.csproj @@ -25,6 +25,7 @@ +