Method Build
Build(string, string, string[], bool)
Builds one directory. Returns a one-line report; never throws at the caller.
public static string Build(string name, string outputPath, string[] rootAssetPaths, bool cleanBuildCache = false)
Parameters
namestringoutputPathstringrootAssetPathsstring[]cleanBuildCacheboolPass UnityEditor.BuildContentOptions.CleanBuildCache, which wipes Unity's build-artifact cache before building and therefore makes the build a cold one — every file re-serialised from scratch.
Default false, and the base build no longer passes it. It was added on 19.09.2026 as a workaround for a corrupted build cache: a stale cache made the build fail with
Gather and collect build metadata: Unexpected header for AssetBuildMetaData blob from VirtualArtifacts/Extra/<hash>.buildmeta, write zero files, and return aBuildReportwhose only signal issummary.result == Failed— and the same asset failed alone in one run and succeeded alone in the next, which cost hours of bisection (measured then:Abandoned Settlement.prefabaloneFailedwithout the flag,Succeeded, 563 fileswith it).That corruption was in the Unity Data Store, not in anything this option repairs. Unity named it itself (
Corrupted artifact … detected in UDS), and afterLibrary/DataStore,Library/BuildCache,Library/ArtifactDBandLibrary/PlayerDataCachewere deleted, the same full build passes with this flag and without it, both atTotalErrors = 0. What the flag still buys is a cold build: measured on the full base directory (29 roots, 18 900 files, 1.33 GB) it costs 11.8–13.3 minutes against 10.2 minutes without — and that gap is the floor a cold cache imposes, on every build, forever. Correctness is now covered byBuildBase's input fingerprint, which skips a build whose input has not changed at all.