From 6e8bf0f2d406d96cd50596a6e81ac9274c851b4d Mon Sep 17 00:00:00 2001 From: MichalPavlik Date: Thu, 21 Nov 2024 14:04:41 +0100 Subject: [PATCH] Use the static factory for creating a logger --- src/Cli/dotnet/commands/dotnet-run/RunCommand.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs b/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs index 56e10007691a..b0b1e947d3ee 100644 --- a/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs @@ -480,8 +480,12 @@ public void Shutdown() static ILogger MakeTerminalLogger(VerbosityOptions? verbosity) { var msbuildVerbosity = ToLoggerVerbosity(verbosity); - var thing = Assembly.Load("MSBuild").GetType("Microsoft.Build.Logging.TerminalLogger.TerminalLogger")!.GetConstructor([typeof(LoggerVerbosity)])!.Invoke([msbuildVerbosity]) as ILogger; - return thing!; + var logger = Assembly.Load("MSBuild") + .GetType("Microsoft.Build.Logging.TerminalLogger.TerminalLogger")! + .GetMethod("CreateTerminalOrConsoleLogger")! + .Invoke(null, [msbuildVerbosity]) as ILogger; + + return logger!; } static string ComputeRunArgumentsTarget = "ComputeRunArguments";