Call BuildPipeline.BuildPlayer on a specific device id?

Hello, I am currently trying to make a tool, which gathers all connected Android devices and shows them in a custom Editor Window.

Then I want to be able to build (and run) to these specific connected devices. I have the gathering code, which works fine, but now I have to handle the building part.
I currently have this code, which is working, but I can only test it with one device, at the moment.

BuildPlayerOptions buildPlayerOptionsAndroid = new BuildPlayerOptions();
buildPlayerOptionsAndroid.scenes = new[] {"Assets/Scenes/SampleScene.unity"};
buildPlayerOptionsAndroid.locationPathName = "Test1.apk";
buildPlayerOptionsAndroid.target = BuildTarget.Android;
buildPlayerOptionsAndroid.options = BuildOptions.AutoRunPlayer;
BuildPipeline.BuildPlayer(buildPlayerOptionsAndroid);

To my awareness, I think this would build to all connected devices, which is not the behaviour I want to achieve.

Any idea how I would achieve this?

I don’t think there’s an API for controlling the deployment targets. You can try poking around in UnityEditor.Android.Extensions.dll but the relevant classes all seem to be internal.

Maybe you’re better off building a Gradle project and then using Gradle/ADB directly to build and run the build on the devices you want.