[Addressables] Resolve Bee Errors: Proper Asset Cleanup Before Build
Solution
Unity 2019.x - Unity 6.3.x
Published Tue, Mar 17
Deleting Addressables assets during the IPreprocessBuildWithReport.OnPreprocessBuild callback results in build failures. The Bee build system in Unity 6 performs file existence checks before this phase. Removing assets during the build loop causes the pipeline to report missing files in Library/Bee/artifacts/AppPkg because the source files are already locked for the packaging process.
Addressables assets are indexed and copied by the Bee build system early in the compilation process. Attempting to delete assets within OnPreprocessBuild triggers a failure because the pipeline expects all assets registered in the AssetDatabase and AddressableAssetSettings to be physically present.
To resolve this, asset manipulation must be performed via a custom build entry point. This ensures the Addressables manifest and the project AssetDatabase are synchronized before the internal build engine initializes.
- Implement a static build method in your script that handles asset filtering.
- Remove the specific Addressables assets or groups using
AssetDatabase.MoveAssetToTrash. - Invoke
AssetDatabase.SaveAssetsandAssetDatabase.Refreshto finalize the project state. - Call
AddressableAssetSettings.BuildPlayerContentfollowed byBuildPipeline.BuildPlayerto finish the Addressables process.
Additional Tips
- Consider using Addressables Labels to filter content rather than physical deletion for faster iteration.
- Verify that your Addressables settings have Build Remote Catalog enabled if deleting local content for remote hosting.
TL;DR
To remove Addressables assets without build errors, ensure deletion occurs via a custom static build method before the BuildPlayer command is invoked, bypassing the early Bee existence check.
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
Content inspired by a Unity discussion post.