Skip to content

Extend build server shutdown tracing #45393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/Cli/Microsoft.DotNet.Cli.Utils/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ public CommandResult Execute(Action<Process> processStarted)

_process.EnableRaisingEvents = true;

#if DEBUG
var sw = Stopwatch.StartNew();
Stopwatch sw = null;
if (CommandLoggingContext.IsVerbose)
{
sw = Stopwatch.StartNew();

Reporter.Verbose.WriteLine($"> {FormatProcessInfo(_process.StartInfo)}".White());
}

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

var exitCode = _process.ExitCode;

#if DEBUG
var message = string.Format(
LocalizableStrings.ProcessExitedWithCode,
FormatProcessInfo(_process.StartInfo),
exitCode,
sw.ElapsedMilliseconds);
if (exitCode == 0)
{
Reporter.Verbose.WriteLine(message.Green());
}
else
if (CommandLoggingContext.IsVerbose)
{
Reporter.Verbose.WriteLine(message.Red().Bold());
var message = string.Format(
LocalizableStrings.ProcessExitedWithCode,
FormatProcessInfo(_process.StartInfo),
exitCode,
sw.ElapsedMilliseconds);
if (exitCode == 0)
{
Reporter.Verbose.WriteLine(message.Green());
}
else
{
Reporter.Verbose.WriteLine(message.Red().Bold());
}
}
#endif

return new CommandResult(
_process.StartInfo,
Expand Down
3 changes: 3 additions & 0 deletions src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ public void Shutdown()
execute(_commandFactory.Create("exec", [VBCSCompilerPath, s_shutdownArg]), ref errors);

// Shutdown toolset compilers.
Reporter.Verbose.WriteLine($"Shutting down '{s_toolsetPackageName}' compilers.");
var nuGetPackageRoot = SettingsUtility.GetGlobalPackagesFolder(Settings.LoadDefaultSettings(root: null));
var toolsetPackageDirectory = Path.Join(nuGetPackageRoot, s_toolsetPackageName);
Reporter.Verbose.WriteLine($"Enumerating '{toolsetPackageDirectory}'.");
if (Directory.Exists(toolsetPackageDirectory))
{
foreach (var versionDirectory in Directory.EnumerateDirectories(toolsetPackageDirectory))
{
var vbcsCompilerPath = Path.Join(versionDirectory, s_vbcsCompilerExeFileName);
Reporter.Verbose.WriteLine($"Found '{vbcsCompilerPath}'.");
if (File.Exists(vbcsCompilerPath))
{
execute(CommandFactoryUsingResolver.Create(vbcsCompilerPath, [s_shutdownArg]), ref errors);
Expand Down
Loading