Search Unity

How is Production vs Development best set up using Cloud Build?

Discussion in 'Unity Build Automation' started by LilGames, Jan 4, 2021.

  1. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    How are we meant to set up Development and Release (some also call "Production") versions of a project using Cloud Build?

    The main problems I see are:
    In Dev:
    - We want full logging
    - We may want cheats enabled (using Defines I guess)

    In Release:
    - We want minimal logging
    - We don't want the cheats enabled (defines not there)
    - We don't want cheat related Scenes included

    There are ways to set up a single project in Cloud Build to have different build settings, but it's too easy to:
    - Accidentally publish with Defines set that shouldn't be
    - Accidentally include the cheat scenes
    - Forget to disable the logging (it can't be controlled from Cloud Build settings AFAIK)

    I'm looking for hints and tips from users who have gone down this route.
     
  2. ollieblanks

    ollieblanks

    Unity Technologies

    Joined:
    Aug 21, 2017
    Posts:
    460
    Hey @LilGames,

    For each Build Target, a Scene List can be configured in the Unity Dashboard, this would override the scenes that are configured and pushed to your repository. (Cloud Build > Config > Select Build Target > Edit Advanced Settings > Edit Scene List)

    Scripting Defines can also be configured on each Build Target. These are appended to the defines you have configured and pushed to your repository.

    If you want the scripting defines overridden by the ones configured in Cloud Build, so that Cloud Build is the only source of truth, you can clear the ones in your repository with the below Pre-Build Bash Script.
    Disclaimer: Please use this script at your own discretion, as it modifies the raw text in your ProjectSettings.asset file, extra care should be taken with Unity upgrades, for example.

    Code (CSharp):
    1. awk '
    2.    BEGIN       {p=1}
    3.    /webGLWasmStreaming/   {print "  scriptingDefineSymbols: {}";p=0}
    4.    /platformArchitecture/     {p=1}
    5.    p' ProjectSettings/ProjectSettings.asset > ProjectSettings/ProjectSettings.tmp && mv ProjectSettings/ProjectSettings.tmp ProjectSettings/ProjectSettings.asset
    To use this script, please do the following:
    1. Save the above content into a file called CloudBuildPreBuild.sh at the root of your repository and check it in
    2. Configure your Cloud Build Build Target to call this script before a build is run (Cloud Build > Config > Select Build Target > Edit Advanced Settings > Pre-Build Script)
    I hope the above tips prove helpful for setting up your build workflow.
     
    tonemcbride and LilGames like this.
  3. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    Thank you. I'll try out the script.