Search Unity

Export method 'PreBuildSettingsENG.SetPreBuildSettings' not found

Discussion in 'Unity Build Automation' started by nethaneY, Jun 25, 2018.

  1. nethaneY

    nethaneY

    Joined:
    Jun 22, 2018
    Posts:
    1
    EDIT: After looking through the logs more indepth, I believe the function cannot be found because the .dll associated with the C# script was not compiled properly. The relevant sections of the log is here:

    2331: [Unity] -r:'/UNITY_PATH/Unity/Unity-2017_3_0f3/Unity.app/Contents/MonoBleedingEdge/lib/mono/2.0-api/Boo.Lang.dll'
    2332: [Unity] @Assets/mcs.rsp
    2333: [Unity] -sdk:2.0
    2334: [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp-Editor.dll
    2335: [Unity] Compilation failed: 1 error(s), 4 warnings


    Hi,

    Anyone know why this error is causing the Unity Cloud compilation to fail? The full error is:

    110: [Unity] ERROR: export method 'PreBuildSettingsENG.SetPreBuildSettings' not found, aborting. Please make sure you are using the correct function signature.
    111: [Unity] ERROR: preExportMethod 'PreBuildSettingsENG.SetPreBuildSettings' failed, aborting.
    112: ! build of 'ccm' failed. compile failed
    113: publishing finished successfully.
    114: Finished: FAILURE

    I have put the script in Assets/Editor and have ensured the classname and function name are correct. I'm at a loss as to what else could be causing the function to not be found.

    Unity version: 2017.3.0f3
    Source control: Bitbucket
    Local build platform: Windows 10
    Build target: Android

    EDIT: Below is the script I have in the Assets/Editor folder:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class PreBuildSettingsENG : MonoBehaviour {
    5.  
    6.     public static void SetPreBuildSettings()
    7.     {
    8.         // Hardcoded apk settings
    9.         UnityEditor.PlayerSettings.Android.bundleVersionCode = 2;
    10.         UnityEditor.PlayerSettings.bundleVersion = "2.7";
    11.         UnityEditor.PlayerSettings.productName = "CCM";
    12.     }
    13. }
    14.  
    Thanks!
     
    Last edited: Jun 25, 2018
  2. TheTaj

    TheTaj

    Joined:
    Jun 26, 2014
    Posts:
    24
    Were you able to find a solution? I'm having this same problem on Unity 2019.4.17LTS where the Unity Cloud can't find the method (even though its in Assets/Editor, the script and method are public/static, and everything is spelled correctly)
     
  3. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Probably a long shot but whenever I've created classes for post/pre export methods I've never derived them from MonoBehaviour. I assumed MonoBehaviour classes were special and could only be instantiated in game.
     
  4. TheTaj

    TheTaj

    Joined:
    Jun 26, 2014
    Posts:
    24
    Yeah, I've attempted making my script a monobehaviour, not a monobehaviour, and a static or non-static class.
    Unfortunately, Unity Cloud will still not recognize the script even though it is able to recognize other scripts
     
  5. TheTaj

    TheTaj

    Joined:
    Jun 26, 2014
    Posts:
    24
    I want to add that I am able to trigger 'LunarConsoleEditorInternal.Installer.DisablePlugin' from the Unity Cloud Build by adding it as a pre-export method.
    For anyone who uses the Lunar Console, this script exists in an editor folder, is not a monobehaviour, and has a static public void 'DisablePlugin'. I can pass the parameter 'UnityEgnine.CloudBuild.BuildManifestObject manifest' into the function and it works correctly.
    Unfortunately, when I try to trigger 'CloudBuildHelper.PreExport' I just get this error:
    Code (CSharp):
    1. [Unity] ERROR: export method 'CloudBuildHelper.PreExport' not found, aborting. Please make sure you are using the correct function signature.
    2. 247: [Unity] ERROR: preExportMethod 'CloudBuildHelper.PreExport' failed, aborting.
    I have tried moving my CloudBuildHelper script into all 3 of the editor folders in my project, including the one directly under Assets/Editor-- I still get this error every time. I really don't understand why this isn't working

    Code (CSharp):
    1. public class CloudBuildHelper
    2. {
    3. #if !UNITY_CLOUD_BUILD
    4.     public static void PreExport()
    5.     {
    6. #else
    7.     public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
    8.     {
    9.         Debug.LogFormat("CloudBuildHelper -- PreExport function called");
    10.  
    11.         int amount = manifest.GetValue<int>("buildNumber");
    12.  
    13.         var playerSettings = Resources.FindObjectsOfTypeAll<PlayerSettings>();
    14.  
    15.         if (playerSettings != null)
    16.         {
    17.             SerializedObject so = new SerializedObject(playerSettings);
    18.  
    19.             // Find the build number property.
    20.             var sp = so.FindProperty("AndroidBundleVersionCode");
    21.  
    22.             var currentValue = sp.longValue;
    23.  
    24.             sp.longValue = currentValue + amount;
    25.  
    26.             // Save player settings.
    27.             so.ApplyModifiedProperties();
    28.             AssetDatabase.SaveAssets();
    29.         }
    30.  
    31.         LunarConsoleEditorInternal.Installer.DisablePlugin();
    32.        
    33. #endif
    34.     }
    35. }
     
  6. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    That all looks ok to me, very similar to my own class. Did you maybe put parantheses into your config by accident? Mine looks like this:

    upload_2021-1-19_10-44-15.png

    And my code looks like this:

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using UnityEditor.Callbacks;
    4.  
    5. public class IncrementBuildNumber : MonoBehaviour
    6. {
    7.     #if UNITY_CLOUD_BUILD
    8.     public static void PreExport( UnityEngine.CloudBuild.BuildManifestObject manifest )
    9.     {
    10.         string build = manifest.GetValue( "buildNumber" , null );
    11.         PlayerSettings.bundleVersion = "1.0";
    12.         PlayerSettings.iOS.buildNumber = build;
    13.     }
    14.     #endif
    15. }
    If I were you I'd try putting a deliberate error into your code just to make sure that it's even being compiled by cloud build.

    p.s. I've also used https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.OnPreprocessBuild.html to run pre build code and it works without having to modify your cloud build config. I'm not sure how you would obtain the manifest though.
     
  7. TheTaj

    TheTaj

    Joined:
    Jun 26, 2014
    Posts:
    24
    Thanks for the reply, I thought about doing a pre-process code but I'm only trying to run this function on specific Cloud Builds that I intend to push to production, so I don't want it running on every build (that, and I need the manifest).

    Code (CSharp):
    1. [Unity] Assets/Editor/CloudBuildHelper.cs(11,57): warning CS0436: The type 'BuildManifestObject' in '/BUILD_PATH/sagewise.bitcoinblast.blast-prod-aab-tj-test/Assets/Editor/BuildManifestObject.cs' conflicts with the imported type 'BuildManifestObject' in 'UnityEngine.CloudBuild, Version=1.0.7556.31655, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/BUILD_PATH/sagewise.bitcoinblast.blast-prod-aab-tj-test/Assets/Editor/BuildManifestObject.cs'.
    My code generates a warning (the code works, I've copied it into the LunarConsole script that I'm able to reference and can confirm it functions as intends) just a couple lines above the failure code
    Code (CSharp):
    1. [Unity] ERROR: export method 'CloudBuildHelper.PreExport' not found, aborting. Please make sure you are using the correct function signature.
    So I can confirm that the script exists, that it is being compiled, and that everything is spelled right (no parenthesis in the call).
    'CloudBuildHelper.PreExport'
    I've also tried re-naming the script and call because I'm running out of reasons this shouldn't work.
    I'll try adding the line 'using UnityEditor.Callbacks' just in case that has any impact
     
  8. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    It sounds like your code is using your custom build manifest class (In Assets/Editor/BuildManifestObject.cs) rather than the cloud build one - that's maybe why the cloud build config system doesn't recognise your function as a valid one (because the build manifest class type is wrong).

    Why do you need a custom build manifest class? It should be included automatically on cloud build.
     
    TheTaj likes this.
  9. TheTaj

    TheTaj

    Joined:
    Jun 26, 2014
    Posts:
    24
    OMG

    Yep, that was it. Looks like this script got added sometime back by a confused dev (ok, it was me).
    Removing the unnecessary script fixes the problem.

    Thanks for saving me a big headache!
     
    tonemcbride likes this.
  10. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Great, glad it's working. I think I might have made a placeholder class for the build manifest myself just so I could check that my code actually worked before I built it on the cloud build system.
     
    victorw likes this.