Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to retrieve file extension for BuildTarget in Pipeline?

Discussion in 'Testing & Automation' started by Xarbrough, Aug 1, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    518
    Is there a way of using Unity's API to build an output path for a BuildPlayer call that includes the correct file extension depending on the output target? Currently, we have to implement this logic ourselves, e.g. when building for Standalone Windows, append ".exe" to the path, when building for Android, append ".apk" and so on. It's totally doable, but feels like redundant code, since Unity is already handling all of this internally. Am I simply missing the API call to get this extension or default output path where I can extract the extension or something like this?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,257
    The output of a standalone build is a folder, so it doesn't have an extension.

    Also, Android builds may now contain more than 1 file (e.g split APKs).

    You can use the PostProcessBuild attribute to get a callback with the built path. For Standalone you know that the file extension is exe (or .app on OSX), I don't know of any other way to obtain this.

    A newer alternative is to use the IPostprocessBuildWithReport which includes a BuildReport object that has more details, maybe that can help you out :)