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/objmay temporarily fix it, but not reliably -
Running
mgcbmanually 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.