Execute a player build (BuildPipeline.BuildPlayer) and report results. Defaults use the project's current Build Settings. Override --target for a different platform or --scene to pick a one-off scene set. Exits non-zero on build failure. --target accepts Unity BuildTarget names, e.
(
ctx: typer.Context,
target: Annotated[
str | None,
typer.Option("--target", "-t", help="BuildTarget (e.g., StandaloneWindows64, Android, WebGL)"),
] = None,
output: Annotated[
str | None,
typer.Option("--output", "-o", help="Output path"),
] = None,
scenes: Annotated[
list[str] | None,
typer.Option("--scene", "-s", help="Scene paths to include (repeatable)"),
] = None,
json_flag: Annotated[
bool,
typer.Option("--json", help="Output as JSON"),
] = False,
)
| 78 | |
| 79 | @build_app.command("run") |
| 80 | def build_run( |
| 81 | ctx: typer.Context, |
| 82 | target: Annotated[ |
| 83 | str | None, |
| 84 | typer.Option("--target", "-t", help="BuildTarget (e.g., StandaloneWindows64, Android, WebGL)"), |
| 85 | ] = None, |
| 86 | output: Annotated[ |
| 87 | str | None, |
| 88 | typer.Option("--output", "-o", help="Output path"), |
| 89 | ] = None, |
| 90 | scenes: Annotated[ |
| 91 | list[str] | None, |
| 92 | typer.Option("--scene", "-s", help="Scene paths to include (repeatable)"), |
| 93 | ] = None, |
| 94 | json_flag: Annotated[ |
| 95 | bool, |
| 96 | typer.Option("--json", help="Output as JSON"), |
| 97 | ] = False, |
| 98 | ) -> None: |
| 99 | """Execute a player build (BuildPipeline.BuildPlayer) and report results. |
| 100 | |
| 101 | Defaults use the project's current Build Settings. Override --target for |
| 102 | a different platform or --scene to pick a one-off scene set. Exits non-zero |
| 103 | on build failure. |
| 104 | |
| 105 | --target accepts Unity BuildTarget names, e.g.: |
| 106 | StandaloneWindows64, StandaloneOSX, StandaloneLinux64, Android, iOS, WebGL. |
| 107 | |
| 108 | Examples: |
| 109 | u build run # Use current settings |
| 110 | u build run -t StandaloneOSX -o Build/Mac/App.app |
| 111 | u build run -t Android -o Build/app.apk -s Assets/Scenes/Main.unity |
| 112 | """ |
| 113 | context: CLIContext = ctx.obj |
| 114 | try: |
| 115 | result = context.client.build.build( |
| 116 | target=target, |
| 117 | output_path=output, |
| 118 | scenes=scenes, |
| 119 | ) |
| 120 | if _should_json(context, json_flag): |
| 121 | print_json(result) |
| 122 | else: |
| 123 | build_result = result.get("result", "Unknown") |
| 124 | if build_result == "Succeeded": |
| 125 | print_success(f"Build succeeded: {result.get('outputPath', '')}") |
| 126 | else: |
| 127 | print_error(f"Build {build_result}", "BUILD_FAILED") |
| 128 | |
| 129 | total_time = result.get("totalTime", 0) |
| 130 | total_size = result.get("totalSize", 0) |
| 131 | print_line(f" Time: {total_time:.1f}s") |
| 132 | print_line(f" Size: {total_size} bytes") |
| 133 | print_line(f" Target: {result.get('target', '')}") |
| 134 | print_line(f" Errors: {result.get('totalErrors', 0)}") |
| 135 | print_line(f" Warnings: {result.get('totalWarnings', 0)}") |
| 136 | |
| 137 | messages = result.get("messages", []) |
nothing calls this directly
no test coverage detected