Unity Build Pipeline
Configure, script, and automate Unity 6.3 LTS player builds: scenes, platform target, scripting
backend, stripping, and headless/CI builds. Targets Unity 6.3 LTS (6000.3).
When to use
- Use when setting up Build Settings/Profiles, choosing a platform and scripting backend
(Mono vs IL2CPP), reducing build size with managed stripping, scripting a repeatable build
with
BuildPipeline.BuildPlayer, or wiring a CI/headless build.
- Use when the project has
ProjectSettings/EditorBuildSettings.asset or a CI build script.
When not to use: authoring a CI service config end-to-end is DevOps; this skill covers
the Unity-side build API and settings. Console/platform certification specifics are
platform-NDA territory. Storefront submission → steam-publish / itch-publish.
Core workflow
- List the scenes to build (File → Build Profiles/Settings → Scene List, or
EditorBuildSettings.scenes). Only listed, enabled scenes ship; scene 0 is the start scene.
- Pick the platform target and switch the active build target if needed
(
BuildTarget / EditorUserBuildSettings).
- Choose the scripting backend (Player Settings): Mono (fast iteration, desktop) vs
IL2CPP (AOT C++; required for many platforms, better perf, harder to reverse). IL2CPP
needs the platform's C++ toolchain installed.
- Tune size/perf: set Managed Stripping Level (Disabled → Minimal → Low → Medium → High)
and protect reflection-only code with a
link.xml. Set Quality Settings per platform.
- Script the build with
BuildPipeline.BuildPlayer(BuildPlayerOptions) and inspect the
returned BuildReport — a non-Succeeded result must fail your pipeline.
- Run headless for CI with
-batchmode -quit -executeMethod, and check the exit code.
- Verify the actual output runs (launch the player), not just that the build returned
without throwing.
Patterns
1. Scripted build with a result check
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
public static class BuildScript
{
[MenuItem("Build/Windows x64")]
public static void BuildWindows()
{
var options = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/Main.unity", "Assets/Scenes/Level1.unity" },
locationPathName = "Builds/Windows/Game.exe",
target = BuildTarget.StandaloneWindows64,
options = BuildOptions.None, // add BuildOptions.Development for a dev build
};
BuildReport report = BuildPipeline.BuildPlayer(options);
BuildSummary summary = report.summary;
if (summary.result != BuildResult.Succeeded)
throw new System.Exception($"Build failed: {summary.totalErrors} errors");
Debug.Log($"Build OK: {summary.totalSize} bytes in {summary.totalTime}");
}
}
2. Headless / CI invocation
# Exit code is 0 on success; -quit ensures the editor closes; -nographics for build servers.
Unity -batchmode -quit -nographics \
-projectPath "/path/to/Project" \
-executeMethod BuildScript.BuildWindows \
-logFile -
3. Protect stripped code with link.xml
<!-- Assets/link.xml — keep types the linker can't see are used (reflection, JSON, plugins). -->
<linker>
<assembly fullname="MyGameRuntime" preserve="all"/>
</linker>
Pitfalls
- A scene loads in the Editor but is missing in the build — it isn't in the Build Settings
scene list (or is disabled).
SceneManager.LoadScene only sees listed scenes.
- IL2CPP build fails on a fresh machine — the platform C++ toolchain (e.g. Windows build
tools, Android NDK) isn't installed. Mono has no such requirement.
MissingMethodException/TypeLoadException only in the build — managed stripping removed
reflection-only code. Lower the stripping level or add a link.xml preserve entry.
- Treating "BuildPlayer returned" as success — always check
BuildReport.summary.result;
it can return with errors.
- Addressables content is stale/missing — Addressables (
com.unity.addressables) need a
separate content build (Build → Addressables) and a profile pointing at the right load
path; a player build alone doesn't rebuild them.
- Shipping a Development build —
BuildOptions.Development enables the profiler/debugging
and is slower; use BuildOptions.None for release.
References
- For a complete multi-platform CI build script (target switching, version stamping,
argument parsing, exit codes) and an Addressables content-build call, read
references/ci-build-script.md.
- Primary docs:
ScriptReference/BuildPipeline.BuildPlayer, Unity Manual build sections
(player settings, managed code stripping).
Related skills
steam-publish / itch-publish — distributing the player you just built.
unity-csharp-scripting — editor scripting conventions used by build scripts.
1---2name: unity-build-pipeline3description: Build and ship Unity 6.3 LTS players: build settings and scenes, player/quality settings, the IL2CPP vs Mono scripting backend, managed code stripping, scripted BuildPipeline.BuildPlayer, and CI/headless builds. Use when configuring or automating a build, choosing a scripting backend, shrinking build size, or when the user mentions Unity build, player settings, IL2CPP, code stripping, or Addressables.4---5
6# Unity Build Pipeline
7
8Configure, script, and automate Unity 6.3 LTS player builds: scenes, platform target, scripting
9backend, stripping, and headless/CI builds. Targets **Unity 6.3 LTS (6000.3)**.
10
11## When to use
12
13- Use when setting up Build Settings/Profiles, choosing a platform and scripting backend
14 (Mono vs IL2CPP), reducing build size with managed stripping, scripting a repeatable build
15 with `BuildPipeline.BuildPlayer`, or wiring a CI/headless build.
16- Use when the project has `ProjectSettings/EditorBuildSettings.asset` or a CI build script.
17
18**When *not* to use:** authoring a CI service config end-to-end is DevOps; this skill covers
19the Unity-side build API and settings. Console/platform certification specifics are
20platform-NDA territory. Storefront submission → `steam-publish` / `itch-publish`.
21
22## Core workflow
23
241. **List the scenes to build** (File → Build Profiles/Settings → Scene List, or
25 `EditorBuildSettings.scenes`). Only listed, enabled scenes ship; scene 0 is the start scene.
262. **Pick the platform target** and switch the active build target if needed
27 (`BuildTarget` / `EditorUserBuildSettings`).
283. **Choose the scripting backend** (Player Settings): **Mono** (fast iteration, desktop) vs
29 **IL2CPP** (AOT C++; required for many platforms, better perf, harder to reverse). IL2CPP
30 needs the platform's C++ toolchain installed.
314. **Tune size/perf:** set Managed Stripping Level (Disabled → Minimal → Low → Medium → High)
32 and protect reflection-only code with a `link.xml`. Set Quality Settings per platform.
335. **Script the build** with `BuildPipeline.BuildPlayer(BuildPlayerOptions)` and **inspect the
34 returned `BuildReport`** — a non-`Succeeded` result must fail your pipeline.
356. **Run headless** for CI with `-batchmode -quit -executeMethod`, and check the exit code.
367. **Verify** the actual output runs (launch the player), not just that the build returned
37 without throwing.
38
39## Patterns
40
41### 1. Scripted build with a result check
42
43```csharp
44using UnityEditor;
45using UnityEditor.Build.Reporting;
46using UnityEngine;
47
48public static class BuildScript
49{
50 [MenuItem("Build/Windows x64")]
51 public static void BuildWindows()
52 {
53 var options = new BuildPlayerOptions
54 {
55 scenes = new[] { "Assets/Scenes/Main.unity", "Assets/Scenes/Level1.unity" },
56 locationPathName = "Builds/Windows/Game.exe",
57 target = BuildTarget.StandaloneWindows64,
58 options = BuildOptions.None, // add BuildOptions.Development for a dev build
59 };
60
61 BuildReport report = BuildPipeline.BuildPlayer(options);
62 BuildSummary summary = report.summary;
63
64 if (summary.result != BuildResult.Succeeded)
65 throw new System.Exception($"Build failed: {summary.totalErrors} errors");
66 Debug.Log($"Build OK: {summary.totalSize} bytes in {summary.totalTime}");
67 }
68}
69```
70
71### 2. Headless / CI invocation
72
73```bash
74# Exit code is 0 on success; -quit ensures the editor closes; -nographics for build servers.
75Unity -batchmode -quit -nographics \
76 -projectPath "/path/to/Project" \
77 -executeMethod BuildScript.BuildWindows \
78 -logFile -
79```
80
81### 3. Protect stripped code with `link.xml`
82
83```xml
84<!-- Assets/link.xml — keep types the linker can't see are used (reflection, JSON, plugins). -->
85<linker>
86 <assembly fullname="MyGameRuntime" preserve="all"/>
87</linker>
88```
89
90## Pitfalls
91
92- **A scene loads in the Editor but is missing in the build** — it isn't in the Build Settings
93 scene list (or is disabled). `SceneManager.LoadScene` only sees listed scenes.
94- **IL2CPP build fails on a fresh machine** — the platform C++ toolchain (e.g. Windows build
95 tools, Android NDK) isn't installed. Mono has no such requirement.
96- **`MissingMethodException`/`TypeLoadException` only in the build** — managed stripping removed
97 reflection-only code. Lower the stripping level or add a `link.xml` preserve entry.
98- **Treating "BuildPlayer returned" as success** — always check `BuildReport.summary.result`;
99 it can return with errors.
100- **Addressables content is stale/missing** — Addressables (`com.unity.addressables`) need a
101 *separate* content build (Build → Addressables) and a profile pointing at the right load
102 path; a player build alone doesn't rebuild them.
103- **Shipping a Development build** — `BuildOptions.Development` enables the profiler/debugging
104 and is slower; use `BuildOptions.None` for release.
105
106## References
107
108- For a complete **multi-platform CI build script** (target switching, version stamping,
109 argument parsing, exit codes) and an Addressables content-build call, read
110 `references/ci-build-script.md`.
111- Primary docs: `ScriptReference/BuildPipeline.BuildPlayer`, Unity Manual build sections
112 (player settings, managed code stripping).
113
114## Related skills
115
116- `steam-publish` / `itch-publish` — distributing the player you just built.
117- `unity-csharp-scripting` — editor scripting conventions used by build scripts.