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";