Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

RSP file per assembly (or folder?)

Discussion in 'Experimental Scripting Previews' started by TJHeuvel-net, Oct 23, 2018.

  1. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    We just updated our large-ish project to use the Incremental Compiler, and just got a slew of new warnings from using Roslyn.

    Thats great, and we fixed a great many in our own codebase. However we are left with 120+ warnings from Asset Store packages, standard assets and other external scripts.

    Fixing those warnings will make it much harder to update the package to a new version, so we opt not to. Would it be possible to supply a different RSP file per assembly definition, or special compilation folder, so we can be more strict with our own code and less so with external packages? Right now you can already set unsafe per assembly, but ideally we'd be able to add more parameters to each asmdef.
     
    Last edited: Oct 23, 2018
    JesOb likes this.
  2. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    Hi @TJHeuvel-net
    I've got good news. This feature will be included in 2019.1 release
     
    David_Knopp likes this.
  3. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    More good news just got notified im allowed to backport this to 2018.3
     
  4. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Awesome, thanks so much! Any details on how this will work?
     
  5. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    Placing a RSP file next to a Asmdef will then be picked up for that specific Asmdef compilation.
    If you have a RSP file in the Asset folder, it will not be used for Asmdef's having RSP files next to them.
     
  6. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    That sounds perfect. We could re-use one rsp file by including it with the @ sign too.
     
    Last edited: Oct 26, 2018
    HaraldNielsen likes this.
  7. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,053
    I like it!
     
  8. sbsmith

    sbsmith

    Joined:
    Feb 7, 2013
    Posts:
    126
    So, can this be used in 2018.3 to suppress warnings from Asset Store purchases only, or is this just for stuff from the package manager (which seem to be the only things I find with asmdef files)?
     
  9. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    @HaraldNielsen Is this in now? Is there any documentation about it? Does the rsp file need to have the same name as the asmdef or anything special?
     
  10. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    There's some info here, but it's very outdated - it references .js files.
     
  11. marrr048

    marrr048

    Joined:
    Aug 13, 2015
    Posts:
    3
    Is there an issue number or something we can use to track this feature? I'm very excited for it.
     
  12. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    I gave it on to our documentation team, will follow up on the state of that.
    The changes landed in 2018.3.0b9, so you should have it.
    To get it working, you need to put either csc.rsp(latest runtime) or mcs.rsp.
     
  13. marrr048

    marrr048

    Joined:
    Aug 13, 2015
    Posts:
    3
    Awesome. Is there still a different filename for editor scripts? Older documentation said to use gmcs.rsp.
     
  14. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    Asmdef targeting only the Editor will behave the same. So csc.rsp or mcs.rsp.
    The biggest difference with rsp files next to asmdef is that it only picks up the one for that runtime. So mcs.rsp will not be picked up if targeting the latest runtime
     
  15. Magasenakwa

    Magasenakwa

    Joined:
    Oct 13, 2018
    Posts:
    91
    Hi

    I'm sorry butI can't figure outhow this rsp files thing work...

    I created the file csc.rsp and placed it in my Assets/folder with the following:
    Code (csharp):
    1.  
    2. -nowarn:0414
    3. -nowarn:0618
    4. -nowarn:0649
    5. -nowarn:0612
    6.  
    This results in absolutely nothing happening at all.

    I tried it before using:
    Code (csharp):
    1.  
    2. -r:System.Drawing
    3. -r:System.Windows.Forms
    4.  
    ...but that also still led to Unity complaining about me notholding the references to the assemblies I added in Visual Studio

    It seems that these rsp files are simply being ignored flat out. Is this a 2018.3+ only feature (but as @Baste notedthe documentation speaks ofJS still so I am guessing not?) or what am I missing? The project I am working on relies heaily on an abandoned asset that is completely broken in 2018.3+ since it's alrerady complaining about shader stuff that was deprecated in 2017.x... Thus, we are stuck using 2018.2.21f and looking at around 80+ warnings all thetime...

    The assembly referencesare for something I actually need and the warning suppression is to save my sanity... but trying to getthesefiles to work with little to none or less than that in the line of "How to" information specific to unity OR in general is doing the opposite of keeping me sane :(

    Can someone please just tell me how to create a rsp file that actually does something? Please? :(
    Thank you
     
  16. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    I believe that there's some compiler version stuff here - if you're on .NET 4.x Equivalent (Roslyn), you use a csc.rsp, and if you're on the .NET 3.5 Equivalent (Mono) from before 2018.3, you use mcs.rps.
     
  17. Magasenakwa

    Magasenakwa

    Joined:
    Oct 13, 2018
    Posts:
    91
    Thanks @Baste. Afet all that struggling I figured it out like 90 seconds after I finally asked for help :p

    Thing is, though, that you and the docs both speak of "Are you using 3.5 or 4+" but I am using .NET 4 and so I used the csc.rsp ... so when that didn't work I thought to myself: "Wait... Maybe the C stands for CPP as in IL2CPP and the M standsfor Mono... Let me try that" ... and so I renamed csc.rsp to mcs.rsp and that worked perfectly!

    Odd... .Net 4.x Mono uses mcs... I think the key thing here is the "Roslyn" part, not the "4.x" part. Did 2018.2 use something liek "4.x Sarah" or something, maybe? :p ;)

    In any event, I got it working so thatnks very much for the assist.Now I just have 2 much more simple questions to add to this:

    EDIT: Never mind. Teh answers were so blindingly obvious that I deserve a facepalm and then have everyone here give me a facpalm too... on MY face... hard :p How do you determine the name of the file? That is basically my question. The editor just says ""it has to match the compiler". How vague can you be? ...until you see it as "The filename must match the name of the compiler app"... Ahhhhh..... So ifI have MCS.EXE then calling my file csc.rsp is daft... and if I want to know what the new file name is then just look at the name of the compiler.... Ahhhhhh.... Facepalm... :)

    Thanks again for the quick assist. Appreciate your time/effort! :)
     
    Last edited: Jul 11, 2019
  18. bddckr

    bddckr

    Joined:
    Sep 13, 2016
    Posts:
    28
  19. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,053
  20. Deleted User

    Deleted User

    Guest

  21. Deleted User

    Deleted User

    Guest

  22. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    94
    To future googlers: rather than manually importing rsp files with
    @
    as @TJHeuvel-net suggested above, you can also add a
    Directory.Build.rsp
    file to your root folder. Its flags will then be picked up by all rsp files in all subfolders automatically. See the rsp docs for more info.
     
    TJHeuvel-net likes this.
  23. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    @Rabadash8820 does that work? Note that we currently don't use MSBuild to compile with, but plan to in the future.
     
  24. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    94
    Interesting; seems to be working. I added a `Directory.Build.rsp` in a parent folder without any asmdefs and removed all my asmdef-associated rsp files, then reimported all my scripts. I have some nullable reference types in those scripts so normally that would result in build warnings, but the `Directory.Build.rsp` file has the `-nullable` flag and I didn't get any warnings on reimport. Didn't Unity recently update their version of Mono/xbuild? Maybe that version of xbuild has feature parity with MSBuild 15.6 (first version that respects `Directory.Build.props`).
     
    Last edited: Jan 19, 2023
  25. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    94
    Ooft, nevermind, I just got a million nullable warnings after another recompile. Not sure why that wasn't happening before. So no, I guess the
    Directory.Build.rsp
    approach does not work (as of Unity 2021.3.16f1 anyway). I was able to use
    @
    to include the base rsp file though (which I renamed to
    csc-base.rsp
    . Another note to future googlers, apparently
    @
    resolves paths relative to the Unity project root, so the contents of the rsp files next to your asmdefs needs to be:


    Code (CSharp):
    1. @Assets/path/to/<base csc>.rsp
    2. # other flags