A batch mode build invocation with the log file argument visible
A batch mode build invocation with the log file argument visible

First checks: why the failure is silent

An Editor build shows you a window and an error. Batch mode shows nothing and simply ends the process, which is how you end up with a failed build and only a missing file to look at. Fix the log path and the exit code first, then add the rest.

Unity.exe -quit -batchmode \
  -projectPath C:/project \
  -executeMethod BuildScript.BuildAndroid \
  -logFile C:/logs/build.log \
  -buildTarget Android

Three things that matter more than argument order

  1. Without -logFile you spend the whole debugging session hunting for the log.
  2. Without -quit the Editor stays alive and CI looks like it hung.
  3. If the static method behind -executeMethod throws, the exit code is non-zero. Ignore it and you read a failure as a success.

What the build method actually decides

Whether you pass the scene list from Build Settings or assemble it in code changes the output. A build that works locally and drops a scene in CI is almost always this.

var scenes = EditorBuildSettings.scenes
    .Where(scene => scene.enabled)
    .Select(scene => scene.path)
    .ToArray();

var report = BuildPipeline.BuildPlayer(
    scenes,
    "build/android/game.aab",
    BuildTarget.Android,
    BuildOptions.None);

if (report.summary.result != BuildResult.Succeeded)
    EditorApplication.Exit(1);

Expected result and next step

On the same commit, a local build and a command line build should produce the same artifact. If the sizes differ, the scene list or the scripting defines diverged, so check the target platform and define list at the top of the log.

Verification scope

Official documentation review

Verified

Reviewed the article's code and procedure against official Unity documentation and marked it ready for publication. This is not a claim of an independent Unity project or device reproduction; version- or device-specific reports will be checked in that environment as follow-up.

Official documentation checkedUnity command line arguments ↗