MSBuild "MSB3073: command exited with code N" in CI
MSB3073 reports that a command MSBuild ran (a pre/post-build event or an Exec step) exited non-zero, so the build fails. The non-zero exit is the symptom - the real error is in that command's own output, which appears just before the MSB3073 line.
What this error means
Build fails with MSB3073 quoting the command and its exit code. The command's stdout/stderr above usually contains the actual failure.
dotnet
error MSB3073: The command "npm run build" exited with code 1.Common causes
A pre/post-build command failed on the runner
A build event runs an external command (npm, a shell script, a tool) that exited non-zero in CI, often due to a missing dependency or environment difference.
The command behaves differently in CI
Paths, env vars, or tool versions differ on the runner, so a command that works locally fails there.
How to fix it
Read the failing command output
- Look at the command's own output just above the MSB3073 line.
- Run the command directly on a comparable environment to reproduce.
- Fix the underlying failure and rebuild.
Make the command CI-safe
- Ensure required tools/deps are installed before the build event runs.
- Use absolute or workspace-relative paths and required env vars.
- Rebuild.
How to prevent it
- Install tools a build event needs earlier in the CI job.
- Keep build-event commands portable across local and CI.
- Move complex steps into explicit, separately-logged CI steps.
Related guides
MSBuild "MSB4181: task returned false but did not log an error" in CIFix MSBuild "MSB4181: The X task returned false but did not log an error" in CI - a wrapped task failed silen…
MSBuild "MSB4018: The X task failed unexpectedly" in CIFix MSBuild "MSB4018: The X task failed unexpectedly" in CI - a build task threw an unhandled exception, ofte…
"The active test run was aborted ... test host process crashed" in CIFix "The active test run was aborted. Reason: Test host process crashed" in CI - the test host died mid-run f…