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

Unity and MSBuild projects

Discussion in 'Package Manager' started by RyanTremblay, Jan 30, 2019.

  1. RyanTremblay

    RyanTremblay

    Joined:
    Aug 31, 2018
    Posts:
    7
    Today, Unity builds C# scripts by directly running the compiler on those source files. Unity generates MSBuild project files as well (e.g. Assembly-CSharp.csproj), but these are basically just for editing the code and verifying that the code builds - Unity does not actually use the dlls produced by these projects.

    Has there been any consideration in switching things up to have the MSBuild project(s) be the only way that the code is built, and ingesting the output assemblies into the Unity project? I feel like this should be the intended direction to take things at this point because:
    1. C# is basically the only language supported in Unity at this point.
    2. MSBuild is now cross platform.
    3. The C# compiler is now cross platform.
    4. NuGet is now cross platform.
    5. Visual Studio is cross platform (via Visual Studio for Mac).
    There are a bunch of obvious advantages to having my Unity scripts managed completely by an MSBuild project:
    1. It becomes trivial to consume OSS via NuGet (it's just an MSBuild PackageReference), where 99.9% of the .NET ecosystem lives, which is very relevant these days with the move to the modern scripting runtime.
    2. It becomes trivial to share private source between my Unity app and my non-Unity app (it's just an MSBuild ProjectReference).
    3. It becomes trivial to take advantage of the entire developer platform built around .NET and C#.
    So - where are things headed in relation to this?
     
  2. astorms

    astorms

    Joined:
    Jan 31, 2018
    Posts:
    50
    I would love to know this as well!! I am just beginning to decide how to package and deliver libraries that I have written for my team. What I want is to just be able to use vanilla .netstandard and Nuget, for reasons you've described above. I don't want to invest in creating packages for a Package system that only works for Unity.
     
  3. benoitv_unity

    benoitv_unity

    Unity Technologies

    Joined:
    Aug 3, 2017
    Posts:
    40
    Hi,

    Unity has its own custom script compilation pipeline and there's no plan to build Package code differently. I don't think there's any plans to switch to MSBuild but you can always ask on the Scripting forum (https://forum.unity.com/forums/scripting.12/).

    Regards,
    Benoit
     
  4. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109