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

"Bring your own `.csproj`" support

Discussion in 'Experimental Scripting Previews' started by Ramobo, Feb 5, 2021.

  1. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    Unity currently generates `.csproj`s and the solution for you. This caters to beginners, but takes power away from advanced users, since any changes to those files are overwritten. You can use `.rsp` files, but those aren't ideal.

    Core proposal:
    • You can create `.csproj`s instead of Assembly Definitions, and can edit them in any way without fear of losing your changes.
    • Unity still generates the solution and a `Directory.Build.props`, which contains useful variables, like `OutputPath`, which points to `Library\ScriptAssemblies`.
    Another option for users, to be implemented as well as the core proposal:
    • Users can place code in a `Code` folder, which they fully control, at the project root. Unity automatically discovers and aggregates build results in this folder.
    • Scripts in this folder are resolved by `[Guid]` attributes instead of `.meta` files. This allows behaviors in pre-compiled assemblies to be referenced, which is useful for modding support: Allow players to make scenes with the game's behaviors without distributing the source code.
    Alternative to the another option:
    • Implement the core proposal, but resolve behaviors in pre-compiled assemblies by an optional `[Guid]` attribute. The GUID in the attribute must be the same as in the `.meta` file.
    • This is probably the better option for organization nuts like me, since they might not like having code separate from the assets of the "part" of the application that it's for. It should also be easier to implement than an entire special folder.
    Supporting aspects:
    • Switch from the clunky .NET Framework project style to the .NET Core SDK style. This is essential for manual modification friendliness.
    • Fully use MSBuild, which supports NuGet.
    • Support using any version of Roslyn by adding the `Microsoft.CodeAnalysis.CSharp` package?
     
    Last edited: Feb 5, 2021
    wwaero, Huszky, JoNax97 and 2 others like this.
  2. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    The biggest problem I see with this is supporting UPM packages. If you want to use custom UPM packages in your project. For that maybe Unity could offer a conversion too which exposes UPM packages as nugets?
     
  3. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    What do you mean? We can have both UPM and NuGet no problem, either on the same or separate windows.
     
  4. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    I started implementing this, with an editor tool. I'll write back once I have something presentable
     
  5. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Ok, so I made the MVP for this, check it out at githu: https://github.com/KuraiAndras/CsprojToAsmdef .
    Right now VSTU is not supported. Also for this work property I will need to generate explicit assembly references for the asmdef files. This will probably take some time and testing tough
     
    SugoiDev likes this.
  6. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Heyyo, I have implemented of the functionality required for this to be used on daily development. https://github.com/KuraiAndras/CsprojToAsmdef It is still not flawless, but most expected functionality works. @xoofx in another thread you mentiend that Unity has plans for supporting SDK-style csprojs and/or NuGet packages, do you have any input for my project, or can you tell anything about the plans?