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.
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
- Re-run the build with detailed or diagnostic verbosity.
- Read the task output immediately above MSB4181 for the actual command and exit code.
- Fix that underlying command or input.
dotnet build -v detailedSurface the Exec failure explicitly
Make the Exec task log its output so the real error is visible instead of a silent false.
<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.LogErroron failure. - Use
ConsoleToMSBuildso Exec output is captured.