Skip to content

Commit e423f31

Browse files
authored
Extend build server shutdown tracing (#45393)
2 parents 1b0a6ee + 29ea046 commit e423f31

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/Command.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ public CommandResult Execute(Action<Process>? processStarted)
4141

4242
_process.EnableRaisingEvents = true;
4343

44-
#if DEBUG
45-
var sw = Stopwatch.StartNew();
44+
Stopwatch sw = null;
45+
if (CommandLoggingContext.IsVerbose)
46+
{
47+
sw = Stopwatch.StartNew();
48+
49+
Reporter.Verbose.WriteLine($"> {FormatProcessInfo(_process.StartInfo)}".White());
50+
}
4651

47-
Reporter.Verbose.WriteLine($"> {FormatProcessInfo(_process.StartInfo)}".White());
48-
#endif
4952
using (var reaper = new ProcessReaper(_process))
5053
{
5154
_process.Start();
@@ -69,21 +72,22 @@ public CommandResult Execute(Action<Process>? processStarted)
6972

7073
var exitCode = _process.ExitCode;
7174

72-
#if DEBUG
73-
var message = string.Format(
74-
LocalizableStrings.ProcessExitedWithCode,
75-
FormatProcessInfo(_process.StartInfo),
76-
exitCode,
77-
sw.ElapsedMilliseconds);
78-
if (exitCode == 0)
79-
{
80-
Reporter.Verbose.WriteLine(message.Green());
81-
}
82-
else
75+
if (CommandLoggingContext.IsVerbose)
8376
{
84-
Reporter.Verbose.WriteLine(message.Red().Bold());
77+
var message = string.Format(
78+
LocalizableStrings.ProcessExitedWithCode,
79+
FormatProcessInfo(_process.StartInfo),
80+
exitCode,
81+
sw.ElapsedMilliseconds);
82+
if (exitCode == 0)
83+
{
84+
Reporter.Verbose.WriteLine(message.Green());
85+
}
86+
else
87+
{
88+
Reporter.Verbose.WriteLine(message.Red().Bold());
89+
}
8590
}
86-
#endif
8791

8892
return new CommandResult(
8993
_process.StartInfo,

src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ public void Shutdown()
4040
execute(_commandFactory.Create("exec", [VBCSCompilerPath, s_shutdownArg]), ref errors);
4141

4242
// Shutdown toolset compilers.
43+
Reporter.Verbose.WriteLine($"Shutting down '{s_toolsetPackageName}' compilers.");
4344
var nuGetPackageRoot = SettingsUtility.GetGlobalPackagesFolder(Settings.LoadDefaultSettings(root: null));
4445
var toolsetPackageDirectory = Path.Join(nuGetPackageRoot, s_toolsetPackageName);
46+
Reporter.Verbose.WriteLine($"Enumerating '{toolsetPackageDirectory}'.");
4547
if (Directory.Exists(toolsetPackageDirectory))
4648
{
4749
foreach (var versionDirectory in Directory.EnumerateDirectories(toolsetPackageDirectory))
4850
{
4951
var vbcsCompilerPath = Path.Join(versionDirectory, s_vbcsCompilerExeFileName);
52+
Reporter.Verbose.WriteLine($"Found '{vbcsCompilerPath}'.");
5053
if (File.Exists(vbcsCompilerPath))
5154
{
5255
execute(CommandFactoryUsingResolver.Create(vbcsCompilerPath, [s_shutdownArg]), ref errors);

0 commit comments

Comments
 (0)