Can Devops Build Automation Pre-Export Method block the build process?

Hi there,

We are looking to use Unity Cloud Build (DevOps Build Automation) as our build platform, however we have ran into an issue.

In order to improve repo size and developer workflow, we use embedded packages for our common libraries/packages of work. As part of this process, each package may contain a .unitypackage containing essential resources for that package that cannot be stored otherwise (prefabs/meshes/textures/etc).

So our process is that we have an editor script that, upon opening the project, will cycle through each embedded package and will import those .unitypackages so the developer has complete access to the assets within which will often be references in scenes/scripts.

The issue we are experiencing with Unity’s DevOps Build Automation is that requirement for those .unitypackages to be imported before builds occur.

We are trying to make use of the “Pre-Export Method” option within the Configuration settings of a DevOps Build Automation to import these packages before the build attempt, however the method itself is not a blocking method. Therefore it will still attempt to build the project before the packages have been imported and will build scenes (that are reliant on some of those assets) in a broken form.

Is it possible to have the build-step blocked until this import process is complete? If so, how? Otherwise would you have any other suggestion to allow us to use Unity’s Cloud Build Automation.

Theoretically, you could create a pre-build script to open the project and execute your method for importing the packages. Then when the actual build step runs the project should have already imported all of the packages and be able to run without issue.

You should be able to test this locally by cleaning out the Library cache and any cached packages for your project. Use Unity Batch Mode to open the project locally and run your methods that import the custom packages. Then use batch mode locally to build the project and see if it works.

You can find more about batch mode here: https://support.unity.com/hc/en-us/articles/9466056266004-How-do-I-build-my-Unity-Project-in-Batchmode-Locally

1 Like

Hi Ben,

Thanks for the suggestion regarding batch mode, we’ll give this a go and report back :+1:

We have attempted both the batch mode method and an alternative method that involves using reflection to access the AssetDatabase.ImportPackageImmediately method.

Both seem to be effective but the benefit of only having to have the project opened once outweighs the current downside of having to use reflection to access this method.

1 Like