Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Exclude scripts/assemblies from generated solution file?

Discussion in 'Scripting' started by Flavelius, Mar 15, 2020.

  1. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Hi,
    i have some editor only plugins, that i don't need to access via script in any way (UMotion for example).
    These currently still exist in the project solution with their scripts/assembly-definitions-defined projects.
    Is there any way i can un-clutter the solution file, meaning remove them permanently?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
  3. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    The options asmdefs allow are more interfacing oriented. When unity generates the solution file it seems to autoinclude every script in the project and asmdefs don't allow preventing that in their options.
    The problem i have is that unity encourages asset store authors to use asmdefs, which is good by itself, but the solution file gets polluted really quickly the more of those assets one uses, if these are only meant for editor-time (and most of those assets use 2 asmdefs at minimum, commonly editor + some kind of runtime).

    Interestingly, it seems there is an option hidden somewhere that allows that, as packages are treated that way, they can be referenced without being directly included in the solution.
    I guess what i may want is an option for asmdefs to allow treating them in a similar way.
     
  4. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,070
    check out the csproj files, there is a Compile directive that directly points to a class file that should be included.
    you basically wrap things up with asmdef, then there is ProjectReference that points to a particular asmdef that should be included in the final project (in Assembly-CSharp.csproj).

    learn more about asmdef, don't just assume, they operate on folders. observe where exactly they're located in the third party libraries.
     
  5. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Thanks for the hints. I'm not assumping they operate on folders, this is not directly the point of my question (although it's what the unity documentation states and what i've observed using them over the time they existed nonetheless). What i assume though is that unity automatically generates the csproj and solution files. I don't see a way to add or modify something without it being overwritten by the next recompile/refresh in unity. But maybe that assumption is wrong and there is a way to control that auto-generation. Can you point me to some info about this?
     
  6. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,070
    there is a comma in my sentence, they DO operate on folders.

    that's true, I wouldn't know how to help you in that regard. I'm sure there has to be a solution, I've seen people make pretty complicated automatic builds.

    maybe you should really google that up (how to prevent overwriting csproj files), because what I said about asmdefs is the answer to the question how to isolate a package.
     
  7. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Ok, my bad, i misread that. I'm still at my starting point then, because i don't want to prevent unity from regenerating the files with changed/added scripts, my only real concern is having whole asmdef-defined assemblies auto-added too.
    And just in case i'm misunderstanding you again or i didn't make my initial question clear enough, i don't mean to control assembly references, that i can obviously do with (/it's the point of) asmdefs, i mean this (smaller example):

    solutionfile.jpg
     
  8. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,070
    well, obviously by removing the corresponding ProjectReference tags in Assembly-CSharp.csproj (as mentioned in post #4).
    you can try to do this manually, but I'm not sure how to preserve these settings in the long run.
    I'm sure Unity supports it though, maybe someone else can help you with that.
     
    Last edited: Mar 16, 2020
  9. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Yes, that is my question; i want to remove the them from the solution and i'm trying to find a way that works with unity, maybe there's an official (hidden?) way to do it.
     
  10. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,070
  11. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    And you don't have to, i asked this question in hopes of answers; if you don't have one it's fine.
     
  12. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
  13. Silvestor

    Silvestor

    Joined:
    Sep 27, 2018
    Posts:
    6
    Who search solution to disable assembly defenitions from compilation.
    Select any not usable platform in asmdef.
    upload_2023-5-1_18-36-30.png
     
    stormvision likes this.
  14. strictfp

    strictfp

    Joined:
    Jul 29, 2020
    Posts:
    13
    @Silvestor thank you for the tip. This made me figure out that you can actually just select 'Editor' in that list, and it will be excluded from the build;

    upload_2024-1-20_16-9-27.png
     
    CodeRonnie likes this.