Skip to content
Latchkey

MSBuild "error MSB4181: the task returned false but did not log an error" in CI

An MSBuild task reported failure (returned false) without logging a specific error message. MSB4181 is the generic wrapper; the actionable detail is in the task's own output just above, or in raising verbosity.

What this error means

dotnet build fails with "error MSB4181: The "Exec" task returned false but did not log an error." after a command run by an Exec task or a custom task exited non-zero.

dotnet
error MSB4181: The "Exec" task returned false but did not log an error.

Common causes

An Exec command exited non-zero quietly

A shell command run by an Exec task failed but its stderr was not surfaced as an MSBuild error, leaving only the generic MSB4181.

A custom task swallowed its own error

A third-party or custom task returned false without calling Log.LogError, so MSBuild reports only the wrapper.

How to fix it

Raise verbosity to see the real failure

  1. Re-run the build with detailed or diagnostic verbosity.
  2. Read the task output immediately above MSB4181 for the actual command and exit code.
  3. Fix that underlying command or input.
Terminal
dotnet build -v detailed

Surface the Exec failure explicitly

Make the Exec task log its output so the real error is visible instead of a silent false.

Project.csproj
<Exec Command="my-tool --build" ConsoleToMSBuild="true" />

How to prevent it

  • Run failing builds at detailed verbosity to expose silent tasks.
  • Have custom tasks call Log.LogError on failure.
  • Use ConsoleToMSBuild so Exec output is captured.

Frequently asked questions

What causes ""error MSB4181: ... returned false but did not log an error""?
A shell command run by an Exec task failed but its stderr was not surfaced as an MSBuild error, leaving only the generic MSB4181.
How do I fix "error MSB4181: ... returned false but did not log an error"?
Raise verbosity to see the real failure

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card