Skip to content

Please stop lying about the exit code of an exec task #11821

@softworkz

Description

@softworkz

Summary

When the Exec/ToolTask runs a process with exit code 0 but it has logged to stderr, the task's exit code is set to -1:

// If the tool exited cleanly, but logged errors then assign a failing exit code (-1)
if (ExitCode == 0 && HasLoggedErrors)
{
ExitCode = -1;
}

It's documented and fine (at least when you have read it) and this surely makes some sense.

But when this happens a message is logged like:

The command "xxxxxxx" exited with code -1.

And this is not OK. It is a blatant lie, because the command HAS NOT exited with code -1.

It has exited with code 0 - and only the task's ExitCode property is set to -1 because some output has been logged to stderr.

Background and Motivation

Two painful days totally wasted due to the incorrect log message and I'm pretty sure I'm not the first one.

Proposed Feature

This is not about changing any behavior.

But please fix the log output to make it clear what has happened instead of printing wrong statements.

Thank you
sw

Metadata

Metadata

Assignees

Labels

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions