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. Dismiss Notice

Problem: CloudBuild with NuGet and Unity 2020.2 did not work

Discussion in 'Unity Build Automation' started by mj-3dqr, Jan 13, 2021.

  1. mj-3dqr

    mj-3dqr

    Joined:
    Mar 30, 2017
    Posts:
    13
    We have been using NuGetForUnity in UCB without any problems for a long time. It worked like a charm.

    Now we have updated to Unity Version 2020.2.X and none of the installed nuget packages is restored during the build. There is also no "Restoring Nuget Packages" Log in the build log file as it was before. It seems like it is just not called. Also no errors concerning nuget package installation.

    NuGetForUnity Version is 2.0.1.

    I also tried to implement a Pre-Export Method to force the restoring, but this also did not work. Neither any log output could be found from this script.

    Switch back to Unity 2020.1.17f1 resolves both of these problems: All Logs are visible and the NuGet packages are included properly.

    Is there a known issue or do i have to do something else, since 2020.2?

    Thanks a lot.
     
    w4der likes this.
  2. mj-3dqr

    mj-3dqr

    Joined:
    Mar 30, 2017
    Posts:
    13
    After some additional tests i want to show you my testscript:

    Code (CSharp):
    1.  
    2. using NUnit.Framework;
    3. using NugetForUnity;
    4. using System.IO;
    5. using UnityEditor;
    6. using UnityEngine;
    7.  
    8. public class CloudPreBuild : MonoBehaviour
    9. {
    10.     public static void NugetRestore()
    11.     {
    12.         Debug.Log("UnityCloudBuild - CloudPreBuild - NugetRestore started");
    13.         NugetHelper.Restore();
    14.     }  
    15. }
    16.  
    17. [InitializeOnLoad]
    18. public static class NugetCloudHelper
    19. {
    20.     static NugetCloudHelper()
    21.     {
    22.         Debug.Log("UnityCloudBuild - NugetCloudHelper - NugetRestore started");
    23.         NugetHelper.Restore();
    24.     }
    25. }
    It can be tested without NuGet: only all lines except the log output have to be commented out. This script can be used to test the malfunction. 2020.1 works fine. 2020.2 unfortunately not.

    In UCB Config i added "CloudPreBuild.NugetRestore" as Pre-Export Method. The NugetCloudHelper should be loaded without any additional config because of the [InitializeOnLoad] Attribute.
     
    w4der likes this.
  3. mj-3dqr

    mj-3dqr

    Joined:
    Mar 30, 2017
    Posts:
    13
    I reported this behavior as a bug and the support team was able to reproduce my request.
    Currently the error has been forwarded to the internal cloud dev team.
     
    w4der likes this.
  4. w4der

    w4der

    Joined:
    Sep 17, 2011
    Posts:
    17
    Any update in this issue? I have the same problem ;(
     
  5. aasoni_other

    aasoni_other

    Joined:
    Dec 6, 2021
    Posts:
    1
    I believe the issue is due to the new Safe Mode https://docs.unity3d.com/2020.2/Documentation/Manual/SafeMode.html
    since 2020.2.
    Unity Cloud Build doesn't run batchmode with the -ignoreCompilerErrors flag which would override the default behavior which is to abort if compilation errors are encountered when importing. Unfortunately if the compiler errors in question are due to missing packages, this also means that NuGetForUnity doesn't get a chance to run and download said packages because the build was already aborted.

    We have solved this by adding the following to our pre-build scripts to restore the nuget packages. Notice the -ignoreCompilerErrors flag that ensures this will run even if compiler errors are encountered while importing.

    # restore nuget packages
    "$UNITY_EXE" -quit -batchmode -ignoreCompilerErrors -projectPath "$WORKSPACE" -executeMethod NugetForUnity.NugetHelper.Restore