Seeing your cache retrieved during a "clean build" is expected behavior if you are using the "Workspace" caching strategy. In contrast, "Library" caching (the default) will not retrieve the cache when you perform a clean build.
Symptoms:
- I noticed my cache is still retrieved when I do a clean build in Unity Build Automation (UBA).
Cause:
Depending on your caching strategy (set in the Advanced Configuration options for your build target), the cache may be downloaded even when performing a clean build:
-
Workspace Caching: If your build target is using Workspace caching, the system will still download the entire cached workspace. To perform a "clean build," it will have to remove the library directory from the cached workspace before building. In that scenario, seeing the cache being retrieved is completely normal.
Please note that if the 'Copy cache from build target' option is enabled, it can pull workspaces containing pending changes, which can cause new build attempts to fail. Please verify that the source target referenced by 'Copy cache from build target' does not have a pending/uncommitted state, or set the copy source to None, before enabling that option.
Please also keep in mind that a clean build does not bypass the copied cache from the build target seed. A clean build only removes the Library directory from a cached workspace, and the same is true for a workspace pulled in via 'Copy cache from build target', i.e., enabling a clean build will not discard a contaminated copy seed.
Since there is currently no detach control in the UI, the only way to fully decouple is to set the cache strategy to Library Caching/None (which changes the incremental-build behavior and, for the None option, means a full rebuild every time). More info about caching strategies can be found in the document linked below.
-
Library Caching (Default): If your build target uses Library caching (the most common option), a clean build means UBA will not download a cached library to the machine. In this scenario, you should not see the cache being retrieved.
- None: If caching is set to None, UBA performs a clean build every time, and no cache is retrieved.
Resolution:
Select the caching strategy that offers the best performance/cost ratio that you are looking for. While workspace caching often provides some gains in speed, it generally has higher storage costs since more data is cached.
Additional Information: