Search Unity

All script references missing when doing cloud builds

Discussion in 'Unity Build Automation' started by slims, May 28, 2019.

  1. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    When performing cloud builds, I get a message like this for every script reference in my scene (probably nearly 100 references are missing):

    187: [Unity] Script attached to 'MainMapCamera' in scene 'Assets/Scenes/devScene.unity' is missing or no valid script is attached.


    Using:

    Unity 2018.3.x
    Bitbucket


    Local builds work fine. If I clone my repo again and rebuild from scratch, I can see all the references in tact in the Editor.

    Unsure where to even begin to figure out how to fix this issue, since it's not reproducible locally. I don't see any reason why the cloud build would nuke all references in my scene.

    UPDATE: I appear to be able to reproduce this intermittently. I resolved it locally by right clicking the folder containing all my scripts and clicking Reimport All. Obviously I can't do this in the cloud build environment, so what is the solution here?

    UPDATE 2: As stated below, I believe the problem has something to do with my assembly definition files not correctly loading. I get this warning earlier on in the build for each assembly file in my project:

    3900: [Unity] The assembly for Assembly Definition File 'Assets/code/aa.asmdef' will not be loaded. Because the assembly for its reference 'Assets/Packages/Packages.asmdef'' does not exist on the file system. This can be caused by the reference assembly not being compiled due to errors or not having any scripts associated with it.


    Locally, when I reimport my code, these warnings go away and everything works fine.
     
    Last edited: May 31, 2019
  2. Trivium_Dev

    Trivium_Dev

    Joined:
    Aug 1, 2017
    Posts:
    78
    Are you uploading your meta files to your repo?
     
  3. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    Yes.
     
  4. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    Update: at my wits end, I tried cloning the repo and starting over again and was able to reproduce the error locally.

    All of my scripts attached to game objects have the error:

    "The associated script can not be loaded. Please fix any compile errors and assign a valid script".

    There are no compile errors. If I build the project in Visual Studio it works fine. I can even enter play mode in the editor (although obviously the game doesn't work at all since no scripts are running). I have 244 warnings for this, no other messages in the console.

    I had a friend clone the repo and they did not have this issue, so it seems intermittent (although on the cloud builds it reproduces 100% of the time).

    Update 2:

    I right clicked the folder containing all my scripts and clicked Reimport All and all the references were fixed. Obviously I can't do this in the cloud build environment, so what is the solution here?
     
    Last edited: May 30, 2019
  5. JackBurfy

    JackBurfy

    Joined:
    May 9, 2019
    Posts:
    4
    Hi there,

    Could you try uploading the version of the project that you did the 'Reimport All' in and then try a "Clean" cloud build (Click the drop down arrow in the Blue 'Build' button and then 'Clean Build')

    The Clean Build will refresh the Library cache on Cloud Build and might help resolve the issue.
     
  6. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    Unfortunately this did not work, I have the same issue.

    It might also be worth noting that my PlayMode and Editor tests are not being run either. It appears that it does not detect them at all. However, in the editor locally they are detected and can be ran normally.

    I wonder if it has something to do with my assembly files/references? I have separate assembly definitions for my scripts, editor tests, playmode tests, in addition to an assembly for code that I got from a Unity asset store package, and a separate assembly that has some code that is shared between my main scripts and this package.

    I'm probably grasping at straws here, but I can't think of any other reasons why these problems are happening, but I am guessing they are sharing the same root problem.
     
  7. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    So I also get this warning for each assembly file:

    3900: [Unity] The assembly for Assembly Definition File 'Assets/code/aa.asmdef' will not be loaded. Because the assembly for its reference 'Assets/Packages/Packages.asmdef'' does not exist on the file system. This can be caused by the reference assembly not being compiled due to errors or not having any scripts associated with it.


    This would explain why none of the scripts will load properly and why the test cases aren't being detected: their assembly files aren't even being loaded.

    However, the assembly files (and their meta files) are indeed on the file system, so I'm not sure why this is happening. It's also strange that I"m not getting compile errors since the assemblies aren't loading. I just get warnings.
     
    Last edited: May 31, 2019
  8. slims

    slims

    Joined:
    Dec 31, 2013
    Posts:
    86
    Final update: I fixed the issue. One of my assemblies had no csharp files, so, as the error points out, no assembly module was actually being created for it. This caused a cascade of failures for all my assemblies to be created because one of them had it as a reference. Once I rectified this, the build worked and all test cases passed.
     
    Last edited: Jun 16, 2019
  9. OnatKorucu

    OnatKorucu

    Joined:
    Apr 18, 2018
    Posts:
    8
    In my case, I generated .gitignore via gitignore.io and I typed "VisualStudio" and "Csharp" along with "Unity" to generate. However, in the generated file *.meta files were being ignored. Not ignoring meta files in Assets folder as I answered in https://stackoverflow.com/a/71134454/10037278 let me push *.meta files into cloud and solved the issue.

    The easiest way to test these kind of things is is pulling your project from cloud into another empty folder in your device and see if it builds or if it has all the files you need.