Search Unity

Problem with BuildScript.PrepareRuntimeData

Discussion in 'Addressables' started by MiroKovac_PixelFederation, Oct 2, 2018.

  1. MiroKovac_PixelFederation

    MiroKovac_PixelFederation

    Joined:
    Mar 8, 2018
    Posts:
    7
    Hi,
    I have complete command line batch for automatic building in headless mode including Addressables bundles.

    So my build script looks like this:

    BuildScript.PrepareRuntimeData(
    isPlayerBuild: true,
    isDevBuild: false,
    allowProfilerEvents: false,
    forceRebuild: true,
    enteringPlayMode: false,
    buildTargetGroup: buildOptions.targetGroup,
    buildTarget: buildOptions.target,
    playerBuildVersion: version,
    playMode: ResourceManagerRuntimeData.EditorPlayMode.PackedMode,
    cacheDataPath: out cacheDataPath
    );

    var buildResult = BuildPipeline.BuildPlayer(buildOptions);


    Where:
    targetGroup is BuildTargetGroup.Android
    target is BuildTarget.Android

    When I run it from command line, function BuildScript.PrepareRuntimeData ignores all dll libraries that are explicitly included on Android - for example Security.dll installed by Unity IAP and fails to build addressables. However if I run the same script with the same parameters from editor dlls are included and everything works.

    I also found a workaround: if I change dll platforms from explicitly selected Include Platforms to just Any Platform addressables are compiled without problems.

    Conclusion:
    It looks like BuildScript.PrepareRuntimeData executed in headless mode has invalid platform in script building step.
     
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    What are the full list of options you are using to start Unity from the command line?
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
  4. MiroKovac_PixelFederation

    MiroKovac_PixelFederation

    Joined:
    Mar 8, 2018
    Posts:
    7
    This is my command line:
    Code (Bash):
    1.  
    2. Unity.exe -batchmode -quit -logFile c:\Work\build.log -buildPath c:\Work\Build -version 1.0.5.145 -buildNumber 145 -name TS2Test -engineVersion 2018.2.10f1 -projectPath c:\Work\Projects\TS2_Prod -executeMethod TS2Editor.Builder.BuildCommand.ExecuteBuild -buildDirectory c:\Work\Build -buildTarget Android -env Test -projectVersion 1.0.5
    3.  
    @liortal your plugin is unfortunately useless for me since you use old Asset Bundles. Also my command line build works, it just needs some small bug fix.
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    the tool is not related to asset bundles, it just "enhances" command line execution.
    BTW i would be happy to hear any feedback for things that can be improved for working with Addressables using it.
     
  6. MiroKovac_PixelFederation

    MiroKovac_PixelFederation

    Joined:
    Mar 8, 2018
    Posts:
    7
    I see, thank you for offer but as I said in original post, I have absolutely no problem with Unity execution from command line. The problem is in platform while building Addressables from command line and that's issue somewhere in Unity.
     
  7. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    @mikovac thanks for the info, we will look into it
     
  8. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    @Ryanc_unity The PrepareRuntimeData command went missing in the newest 0.4.6 version of the Addressables System. However Unity still doesn't build the data in batch mode.

    What command shall we use instead?
     
  9. zkorosi

    zkorosi

    Joined:
    Jan 24, 2017
    Posts:
    4
    I've been looking for a solution as well.
     
  10. MiroKovac_PixelFederation

    MiroKovac_PixelFederation

    Joined:
    Mar 8, 2018
    Posts:
    7
    @Pixel2015 Good to know, I'm not gonna update to newest version until it's fixed.

    @Ryanc_unity Is there any workaround to missing PrepareRuntimeData?
     
  11. zkorosi

    zkorosi

    Joined:
    Jan 24, 2017
    Posts:
    4
    Okay, we've found a solution. Call this function from your batchMode build method:

    Code (CSharp):
    1. public static void PrepareRuntimeData(BuildPlayerOptions buildOptions)
    2.         {
    3.             var settings = AddressableAssetSettingsDefaultObject.Settings;
    4.             if (settings == null) {
    5.                 return;
    6.             }
    7.          
    8.             var context = new AddressablesBuildDataBuilderContext(
    9.                 settings,
    10.                 buildOptions.targetGroup,
    11.                 buildOptions.target,
    12.                 (buildOptions.options & BuildOptions.Development) != BuildOptions.None,
    13.                 false,
    14.                 settings.PlayerBuildVersion);
    15.          
    16.             settings.ActivePlayerDataBuilder.BuildData<AddressablesPlayerBuildResult>(context);
    17.         }