Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Batch mode: Automated builds for Android - Package Manager refresh?

Discussion in 'Testing & Automation' started by Andrew_S1, Dec 10, 2021.

  1. Andrew_S1

    Andrew_S1

    Joined:
    Oct 10, 2018
    Posts:
    5
    Hi, I have a batch file which can create builds for Android given that there are no script compilation errors and all assets are imported.

    I have been using
    Code (CSharp):
    1. AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
    which triggers the AssetDatabase to refresh for Assets only. Assets successfully import as shown in the AppData/Local/Unity/Editor/Editor.log file.

    Our product currently supports several XR platforms (including Oculus Quest and Pico XR) where we swap out different Package manifest.json files via the custom build function in our editor build script.

    Assets successfully import but packages don't add or remove based on the manifest file when running in batchmode/headless, which causes our assembly definitions to have missing references to packages that have their own assembly definitions that aren't already added.

    Opening the project normally in Unity solves this problem and the links are fixed, but I want to have a way to call package manager to update packages without having to open Unity in the first place. The goal is to have this work in our cloud build solution.

    I cannot just add the missing packages through import requests as this happens asynchronously and the build script will attempt to start a build before the packages are done importing.

    Is there an easier way for this?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
  3. Andrew_S1

    Andrew_S1

    Joined:
    Oct 10, 2018
    Posts:
    5
    @superpig Thank you very much. That worked.

    Code (CSharp):
    1. using UnityEditor.PackageManager;
    was what I needed in order to access Client.Resolve();
     
    superpig likes this.