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

UCB Ignoring csc.rps?

Discussion in 'Unity Build Automation' started by stephen_mxr, Apr 23, 2020.

  1. stephen_mxr

    stephen_mxr

    Joined:
    Sep 19, 2019
    Posts:
    5
    We have a project in UCB that uses a submodule in git for some common code. We've recently added some preprocessor symbols to the csc.rsp file to control whether a few classes that have external dependencies are compiled (for example some Vuforia utilities since not all of our projects use Vuforia). This works fine when building locally, but they seem to be completely ignored when doing a cloud build. When it gets to compiling one of the assemblies, it throws a "type or namespace name [...] could not be found" error. I checked the list of /defines that get output into the log when compilation fails, and the ones added in csc.rsp are not in there. The file is definitely in source control, and has definitely been updated to contain the new preprocessor symbols.

    Does UCB somehow ignore or overwrite the csc.rsp file?
     
  2. ollieblanks

    ollieblanks

    Unity Technologies

    Joined:
    Aug 21, 2017
    Posts:
    432
    Cloud Build handles scripting defines by injecting its own csc.rsp file, which is a likely culprit for this behaviour.

    To add custom scripting defines to a build, please do the following:
    1. Navigate to the project on the Developer Dashboard
    2. Select Cloud Build > Config from the left hand menu
    3. Click on Edit Advanced Options for the Build Targets you wish to configure
    4. Add custom defines and Save changes

    Hope this helps!
     
  3. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    We do delete the defines from .rsp files - as @ollieblanks mentions the recommended way to configure defines (both in Cloud Build and the Unity Editor) is not to use rsp files but instead to add scripting defines. This is because csc.rsp has a very limited scope and so your defines will not be applied globally to your Unity project, instead they are applied directly to specific invocations of the C# compiler.

    With that said, I'm looking at the code now and it seems like you should be able to bypass the deletions by adding them using the shorthand -d instead of -define.
     
  4. stephen_mxr

    stephen_mxr

    Joined:
    Sep 19, 2019
    Posts:
    5
    Thanks for the info.

    Scripting defines in the player settings are great for per platform defines, but annoying when you're developing for multiple platforms. You have to individually add them to each platform, and can't add them to a build platform that you don't have installed (for example, I don't have iOS build target installed on my Windows development machine because it's multiple gigabytes and I can't do a full build on there, and switching platforms to iOS, building the Xcode project then copying the build to a macOS device to build the Xcode project is more annoying than simply pulling the project down to a macOS device and building from there). Similarly, the scripting defines in cloud build are great when you need different defines for the different configs in a single project, but annoying for things that apply globally.

    Personally, I don't think UCB should be removing defines in the response file, but if that "feature" is going to remain, it would be nice to see it added to the documentation somewhere, as its not mentioned on either the UCB scripting define page, nor the general platform dependent compilation page.

    I'm curious about this, what other parts of Unity use the scripting defines? I thought they were only used by the compiler?
     
    SolidAlloy likes this.
  5. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    You can add scripting defines to platforms that you do not have installed, just configure them in the developer dashboard for the target. If you are a power user who is maintaining enough targets that this becomes unwieldy then it's relatively easy to automate build target creation and updates via the build API.

    There are other rsp files which apply to different compilation scenarios e.g. smcs.rsp, mcs.rsp, us.rsp and gmcs.rsp. In the current version of the Editor this is no longer a huge issue but in the past this was a major cause of confusion and as such the documentation about platform-dependent compilation explicitly warned users against using RSP defines.