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