Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5.5b6 PreExport

Discussion in 'Unity Build Automation' started by Kujo87, Oct 11, 2016.

  1. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Hi,

    I have a method that handles the sets the iOS and Android build numbers before a cloud build starts and sets which target store to use on Android, which has been working fine. but I've just run a build on 5.5b6 and it failed. Looking through the logs, I found this:

    Code (csharp):
    1. 30732: [Unity] ERROR: preExportMethod 'CloudBuildHelper.PreExport' failed, aborting.
    2. 30733: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    3. 30734: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4. 30735: [Unity] UnityEngine.Logger:Log(LogType, Object)
    5. 30736: [Unity] UnityEngine.Debug:Log(Object)
    6. 30737: [Unity] UnityEditor.CloudBuild.BuildLogger:Log(String, Object[])
    7. 30738: [Unity] UnityEditor.CloudBuild.Builder:Build()
    Not a ton of info with it, just that.

    The CloudBuildHelper.PreExport is attached as well:

    Code (csharp):
    1.  
    2. public class CloudBuildHelper : MonoBehaviour
    3. {
    4.     #if  UNITY_CLOUD_BUILD
    5.     public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
    6.     {
    7.         string build = manifest.GetValue("buildNumber", null);
    8.         PlayerSettings.iOS.buildNumber = build;      
    9.         int buildNo = 1;
    10.         int.TryParse(build, out buildNo);      
    11.         PlayerSettings.Android.bundleVersionCode = buildNo;
    12.  
    13.         #if UNITY_ANDROID
    14.             #if UNITY_AMAZON
    15.                 UnityEngine.Purchasing.UnityPurchasingEditor.TargetAndroidStore(UnityEngine.Purchasing.AndroidStore.AmazonAppStore);
    16.             #else
    17.                
    18. UnityEngine.Purchasing.UnityPurchasingEditor.TargetAndroidStore(UnityEngine.Purchasing.AndroidStore.GooglePlay);
    19.             #endif
    20.         #endif
    21.     }
    22.     #endif
    23. }
    24.  

    Has anything changed with the PreExport methods in 5.5?

    Thanks
     
  2. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    This has to do with an issue that was introduced in Unity 5.5 beta that caused UnityEngine.Purchasing namespace to not be available when building from command line (such as Unity Cloud Build). Should be fixed in one of the upcoming 5.5 beta releases.
     
  3. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Thanks for the response, I'll remove it for now
     
  4. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Hi @dannyd - following on from what you said, I just removed the Purchasing code so I can still use the build numbers from Cloud, but I still get the same error.

    The simplified Script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class CloudBuildHelper : MonoBehaviour
    5. {
    6.     #if  UNITY_CLOUD_BUILD
    7.     public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
    8.     {
    9.         string build = manifest.GetValue("buildNumber", null);
    10.        
    11.         Debug.Log("Build: " + build);
    12.         PlayerSettings.iOS.buildNumber = build;
    13.        
    14.         int buildNo = 1;
    15.         int.TryParse(build, out buildNo);
    16.        
    17.         PlayerSettings.Android.bundleVersionCode = buildNo;
    18.     }
    19.     #endif
    20. }
     
  5. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    PlayerSettings is in the UnityEditor namespace. Just add a "using UnityEditor;" directive at the top of the file. Also, double check that this CloudBuildHelper script is within an Editor/ folder in your project.
     
  6. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Hi @dannyd tried adding the using directive, but still failing out with the same error codes. It is in the Editor folder as well

    I'll send you the projectID if that helps
     
  7. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Yes, please do.
     
  8. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Sorted - thank you!
     
  9. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    No problem. Glad you got it worked out!
     
  10. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    A question from the back of this - how come it doesn't output what the actual error was during the pre-export? As it turns out, it was a simple error, but there was no useful info in the logs for it to track it down. Just failed...
     
  11. unitychrism

    unitychrism

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    122
    Hi there,

    That's a good question, please direct message me a link to an example build that failed so I can review the log content.

    Thanks,
    -Chris