We have a build pipeline that opens the Unity IDE in batch mode and invokes a method that first configures a number of project settings, based on command line arguments it is passed, before eventually building the player.
I have been attempting to integrate the UnityPurchasingEditor.TargetAndroidStore API into this process and have found that calling this method with AppStore.UDP as a parameter results in a dialog that reads “In order to use this functionality, you must install or update the Unity Distribution Portal Package”. This is despite the package being present in both the Packages/manifest.json file and Library/PackageCache folder.
If I manually set the store to UDP by using the “SwitchStore” menu item or by directly manipulating the BillingMode.json file and then run the same build script (with calls to UnityPurchasingEditor.TargetAndroidStore removed) everything works as expected.
I am using Unity 2020.3.34f along with v4.4.1 of the com.unity.purchasing package and v2.0.0 of the com.unity.purchasing.udp package.
Is there something I am missing here that will allow me to use the UnityPurchasingEditor.TargetAndroidStore when building from the command line using batchMode?
EDIT - It’s also worth noting that I have unsuccessfully attempted to call it from a IPreprocessBuildWithReport.OnPreprocessBuild method, thinking that package resolution when Unity is opened may have been the issue.