[MonoGame / Android] Random MGCB failure during dotnet build (MSB3073) exit code -532462766

I ran into a random build failure when packaging a MonoGame Android project using:

dotnet build -c Release -f net9.0-android -p:AndroidBuildApplicationPackage=true

Typical error:

MonoGame.Content.Builder.Task.targets(172,5): error MSB3073:
"dotnet" "mgcb" ... exited with code -532462766

Symptoms:

  • Happens randomly (sometimes works, sometimes fails)

  • Cleaning bin/obj may temporarily fix it, but not reliably

  • Running mgcb manually works fine

  • Multiple dotnet / mgcb processes observed during build

Cause:

This is not a content or cache issue.

It’s caused by MSBuild parallelism — MGCB gets invoked concurrently, leading to race conditions on Content/obj intermediate files.

Fix:

Run the build in single-thread mode:

dotnet build MyGame01Android.csproj -c Release -f net9.0-android -p:AndroidBuildApplicationPackage=true -m:1 -nr:false -p:BuildInParallel=false

Conclusion:

MGCB is not safe under concurrent execution in this setup.

Disabling parallel build makes the process stable.

Well there isn’t enough info here to say what’s happening for sure, but at face value…

MSBuild parallelism builds multiple projects at the same time. If you have multiple projects building in parallel that run MGCB to process the same .mgcb (or different ones that output to the same place) then of course they’re going to conflict. They’re 2+ independent processes writing files of the same names to the same paths. If you want to build multiple projects concurrently just remove the content builder task from them and run it manually via mgcb editor or cli when you update any content files instead. Or, depending on how your projects are setup, set your mgcb to output obj/bin paths based on target platform so they’re written to different places, then they could run concurrently.