Search Unity

Addressables with build server

Discussion in 'Addressables' started by ProtoTerminator, Jan 21, 2020.

  1. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    I built our WebGL game locally and uploaded to S3 and everything worked fine. So I then pushed my branch up on git which our build server automatically makes a new build from. Problem I'm having now is that the build coming from the build server is requesting the wrong catalog. It request
    catalog_2020.01.21.03.12.57.hash
    when the build server generated
    catalog_2020.01.21.03.52.19.hash
    . I force added
    Library/com.unity.addressables/*
    to the git commit. So, what am I missing? Should I not have committed the library?

    @DavidUnity3d
     
  2. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hm.. that's interesting. Is your build server strictly doing a player build or are you doing an Addressable content build as part of your automation? Also what version of the package are you using?
     
  3. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    This is the build script I'm running. So I build the engine then I build the addressables content and copy it into the built streamingassets (after running a gzip compression on them). I'm using Unity 2019.1.14 and Addressables 1.5.1.


    Code (CSharp):
    1. static void Build(BuildTarget buildTarget)
    2. {
    3.     var buildString = buildTarget.ToString();
    4.  
    5.     BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    6.     buildPlayerOptions.scenes = new[] { "Assets/Scenes/init.unity" };
    7.  
    8.     buildPlayerOptions.locationPathName = "Builds/academy";
    9.  
    10.     buildPlayerOptions.target = buildTarget;
    11.     buildPlayerOptions.options = BuildOptions.None;
    12.  
    13.     BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
    14.     BuildSummary summary = report.summary;
    15.  
    16.     if (summary.result == BuildResult.Succeeded)
    17.     {
    18.         UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent();
    19.         DirectoryInfo addressablesDir = new DirectoryInfo(Application.dataPath.Replace("Assets", "AssetBundles"));
    20.         Compress(addressablesDir);
    21.         addressablesDir.MoveTo(Application.dataPath.Replace("Assets", "Builds/academy/StreamingAssets/AssetBundles"));
    22.  
    23.         Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
    24.     }
    25.     else if (summary.result == BuildResult.Failed)
    26.     {
    27.         Debug.Log("Build failed");
    28.     }
    29. }
     
  4. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    Interesting, I removed the Library on a commit and let the server build again, and running that one spit an error I assume from stripping.

    Code (CSharp):
    1. MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
     
  5. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Can you try doing the opposite of that on your build script? We typically assume you've built the addressable content before the player build and we handle the copying over for you. So if you could change your script to build the Addressable content and then on that build success try building the player that might solve your problem.

    I'd have to look to know for sure but I imagine the old catalog version is getting baked into the build, then you're generating a new build (which will make a new catalog) and copying that into the streaming assets.

    That code stripping thing doesn't sound great. During part of our content build we generate a link.xml that should prevent that code from getting stripped. Since you're doing your player build first we haven't generated the link.xml (which was probably previously in the Library content you manually committed so once you deleted that you no longer had that protection against code stripping).

    Hope that helps! Let me know if you still have trouble.
     
  6. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    @DavidUnity3d Thanks! Doing that it now requests the proper catalog. But now I have another error.

    Code (CSharp):
    1. Exception encountered in operation Resource<IAssetBundleResource>(global_art_manager.bundle): Invalid path in AssetBundleProvider: 'AssetBundles/WebGL/scriptableobjects_assets_art/global_art_manager.bundle'.
    It's telling me that this is an invalid path. I'm not sure why it doesn't include the full path to the S3 bucket, I provide that when I initialize the addressables (which that clearly works since it's able to grab the catalog). And I checked that location on S3 and that bundle does exist there.


    This is my build script now:

    Code (CSharp):
    1. static void Build(BuildTarget buildTarget)
    2. {
    3.     var buildString = buildTarget.ToString();
    4.  
    5.     // Build addressables
    6.     UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent();
    7.     DirectoryInfo addressablesDir = new DirectoryInfo(Application.dataPath.Replace("Assets", "AssetBundles"));
    8.     Compress(addressablesDir);
    9.     addressablesDir.MoveTo(Application.streamingAssetsPath + "/AssetBundles");
    10.  
    11.     BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    12.     buildPlayerOptions.scenes = new[] { "Assets/Scenes/init.unity" };
    13.  
    14.     buildPlayerOptions.locationPathName = "Builds/academy";
    15.  
    16.     buildPlayerOptions.target = buildTarget;
    17.     buildPlayerOptions.options = BuildOptions.None;
    18.  
    19.     BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
    20.     BuildSummary summary = report.summary;
    21.  
    22.     if (summary.result == BuildResult.Succeeded)
    23.     {
    24.         Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
    25.     }
    26.     else if (summary.result == BuildResult.Failed)
    27.     {
    28.         Debug.Log("Build failed");
    29.     }
    30. }
     

    Attached Files:

    Last edited: Jan 21, 2020
  7. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hmm... so the Addressable Group you have your scriptable objects in is set to use Remote Build and Load paths and your Profile has the correct build and load paths setup? The catalog provider is different than the asset bundle provider so I just want to make sure your groups are setup correctly.
     
  8. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    Oh, woops. I had the load path set to the remotebuildpath. Fixing that. :)
     
  9. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    All working now, thanks!
     
    davidla_unity likes this.