From 4aa1c42551a2a98bb2f1277b6347ac67b4a1d48d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Oct 2026 10:58:54 +0000 Subject: [PATCH] fix: Handle DocFX exit codes in BuildCommand - Change Utils.RunCommand return type from Task to Task to return process exit code - Capture exit code from DocFX command in BuildCommand - Check if exit code is non-zero and skip further processing if DocFX fails - Log error message with exit code when DocFX fails Fixes: Extract changes from PR #9 Co-authored-by: bdovaz <950602+bdovaz@users.noreply.github.com> --- UnityXrefMaps/Commands/BuildCommand.cs | 14 +++++++++++++- UnityXrefMaps/Utils.cs | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/UnityXrefMaps/Commands/BuildCommand.cs b/UnityXrefMaps/Commands/BuildCommand.cs index 6399abd..7aa1a18 100644 --- a/UnityXrefMaps/Commands/BuildCommand.cs +++ b/UnityXrefMaps/Commands/BuildCommand.cs @@ -149,7 +149,7 @@ public BuildCommand(ILoggerFactory loggerFactory) logger.LogInformation("Running DocFX on '{RepositoryTag}'", repositoryTag); } - await Utils.RunCommand( + int exitCode = await Utils.RunCommand( "docfx", docFxArguments, value => { @@ -173,6 +173,18 @@ await Utils.RunCommand( }, cancellationToken); + if (exitCode != 0) + { + result = false; + + if (logger.IsEnabled(LogLevel.Error)) + { + logger.LogError("DocFX exited with code {ExitCode} for Unity '{RepositoryTag}'", exitCode, repositoryTag); + } + + continue; + } + if (!File.Exists(generatedXrefMapPath)) { result = false; diff --git a/UnityXrefMaps/Utils.cs b/UnityXrefMaps/Utils.cs index 8b88a27..6e49723 100644 --- a/UnityXrefMaps/Utils.cs +++ b/UnityXrefMaps/Utils.cs @@ -39,7 +39,7 @@ public static async Task CopyFile(string sourcePath, string destPath, Cancellati /// The arguments of the command. /// The function to call with the output data of the command. /// The function to call with the error data of the command. - public static async Task RunCommand(string command, string arguments, Action output, Action error, CancellationToken cancellationToken = default) + public static async Task RunCommand(string command, string arguments, Action output, Action error, CancellationToken cancellationToken = default) { using var process = new Process(); process.StartInfo = new ProcessStartInfo(command, arguments) @@ -58,6 +58,8 @@ public static async Task RunCommand(string command, string arguments, Action