Hello,
I have two tarball packages, one for development and one for release.
I wish to change which package is in the project at build-time (using development package when making release build results in compilation errors).
I’ve tried using UnityEditor.PackageManager.Client in OnPreprocessBuild, but the package is resolved/changed AFTER the build fails.
Ideally it should also work in batch mode.
Any help would be much appreciated!
Cheers,
Daniel
I woud also like to know if this is possible. Thanks
Hello DanielFritsdal and swan-mark-grounding,
Unity resolves and locks packages before the build process begins — including during OnPreprocessBuild. So changing packages at that point is already too late.
Unfortunately Unity does not provide an event to hook on too that could help you in that case. What I can suggest is to create a script outside Unity (or a custom build step) to modify manifest.json of your project before Unity starts building. You’ll need to swap the tarball dependency before Unity enters the build pipeline. This can work in batch mode as well 
I have a build system that intercepts the Build command to realize build preparations, like setting the ProjectSettings, building the Addressables, and any other custom thing I need to do before the build really starts.
Since last week I’ve been trying to deal with removing a Package that I cannot build, for context:
The Epic Online Services SDK currently has an issue with Windows 32-bit builds, where the game will immediatelly crash at launch due to some DLL problem. So I need to remove the EOS SDK before triggering a Steam build.
But, once the Package is removed via Client.Remove() and the code base gets reloaded, my code execution (which was waiting for the package removal gets finished to then proceed to execute the BuildPipeline.BuildPlayer(options)) just stops executing. I guess the reason is the Domain reload that resets any code execution. 
Any hints in my case?
Hello! Are there any future plans for an API to work synchronously with upm?
Sometimes there are editor packages that, for some reason, contain runtime scripts or resources. It would be great to be able to cut out the entire package at the preprocessing stage so that junk doesn’t get into the build.