Skip to content

Commit

Permalink
ToolTask process start separated to another function (#9649)
Browse files Browse the repository at this point in the history
Fix for #9404

Context
We currently do not send the cancelation event to tasks being run by ToolTask, as such, many children task take a long time to cancel, and sometimes they finish executing before said cancelation.
This change makes it possible for inherited classes to access the process and check the cancelation event during execution.

Changes Made
Separated the start of the process to another function that is overridable, as well as exposing the process information.

Notes
Issue will only be closed once C++ team has incorporated this change into the CustomBuild task.
  • Loading branch information
maridematte authored Jan 19, 2024
1 parent 0932b43 commit 6d97976
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Utilities/ToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,19 @@ protected virtual ProcessStartInfo GetProcessStartInfo(
return startInfo;
}

/// <summary>
/// We expect tasks to override this method if they need information about the tool process or its process events during task execution.
/// Implementation should make sure that the task is started in this method.
/// Starts the process during task execution.
/// </summary>
/// <param name="proc">Fully populated <see cref="Process"/> instance representing the tool process to be started.</param>
/// <returns>A started process. This could be <paramref name="proc"/> or another <see cref="Process"/> instance.</returns>
protected virtual Process StartToolProcess(Process proc)
{
proc.Start();
return proc;
}

/// <summary>
/// Writes out a temporary response file and shell-executes the tool requested. Enables concurrent
/// logging of the output of the tool.
Expand Down Expand Up @@ -714,7 +727,7 @@ protected virtual int ExecuteTool(
ExitCode = -1;

// Start the process
proc.Start();
proc = StartToolProcess(proc);

// Close the input stream. This is done to prevent commands from
// blocking the build waiting for input from the user.
Expand Down

0 comments on commit 6d97976

Please sign in to comment.