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

Mono Upgrade NET 6 support

Discussion in 'Experimental Scripting Previews' started by Huszky, Feb 18, 2021.

  1. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Since yesterday Microsoft announced the first .NET 6 preview it might be time to open this thread.

    Announcement:
    https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-1/

    The biggest thing is that might be good for unity is that the mono runtime will be integrated into .NET and so TFMs will be available for window, android, ios, maccatalyst, macos, tvos.

    Do you have any public roadmap for upgrading to .NET 6?
    Do you have any plan on integrating with the standard .NET toolchain? Csproj files not auto generated, can be put under version control, nuget support, etc (this would also mean replacing asmdef?)?
    net6.0-unity as workload please ?https://github.com/dotnet/designs/blob/main/accepted/2020/workloads/workloads.md

    Thanks in advance for @JoshPeterson for answering people's obvious questions about it.
     
    strich likes this.
  2. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    From Blog:
    We’ve been watching the Xamarin team innovate with the XAML Hot Reload experience over the last couple years and started to imagine enabling hot reload as a general .NET capability, and not just for XAML, but C#/IL. We’re defining a new hot code reload model that we can offer for all app types. It’s likely at least some of this feature will be implemented in the runtime, and we’re committed to doing that with both CoreCLR and Mono. We want to enable a very fast build, and even faster operations for code changes that can skip the build entirely, as a new standard feature of .NET.
     
    Arkade likes this.
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    No, nothing public to report yet. I can say that we are actively working now toward the goal of .NET 5/.NET 6 class library support in Unity. Since .NET 6 will be a long term support release from Microsoft, we will likely target .NET 6 instead of .NET 5 for the first .NET Core-based release of Unity, but that is still uncertain.

    This is a bit outside of the area my team supports, so I'm not as sure about these questions. I know there have been some discussions about moving to .csproj files from .asmdef, but I don't think there is any active work here yet. I doubt that Unity will have built-in support for nuget soon.

    I don't expect this to happen. From a class library perspective, I think Unity will support .NET FW (probably version 4.8), .NET Standard 2.1, and .NET 5/6 in the future. Although Unity has a pretty large C# API, I don't expect us to try to publish a TFM now. In essence, that means the Unity API would only be available in Unity, and not via nuget, for example. That would still allow parity with the current approach Unity has. So although have a Unity TFM would be interesting, _not_ having one doesn't loose anything.

    I'd love to have more details to share, but we're not ready to announce roadmaps publicly at this time.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Yeah, this is a really cool feature, and something that we have experimented with internally as well. It is certainly on our list of things to do.
     
    TextusGames, Oneiros90, gtk2k and 8 others like this.
  5. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
  6. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
  7. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    What made you think so? Was it pointless NET 5 thread that existed for 1+ years and ended up dead?
     
  8. Knil

    Knil

    Joined:
    Nov 13, 2013
    Posts:
    66
  9. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    ModLunar, Anthiese and PutridEx like this.
  10. stevphie123

    stevphie123

    Joined:
    Mar 24, 2021
    Posts:
    82
    Man... I was hoping that Unity would move to coreclr completely, years ago... People been complaining how slow mono was and still is even today
     
  11. Bip901

    Bip901

    Joined:
    May 18, 2017
    Posts:
    71
    .NET 6 was just released. Interestingly, the diagram in the linked article depicts Unity as using .NET 6!

    Is it a mistake or has the dream come true?
     
    Qbit86 likes this.
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Leon_NET and Qbit86 like this.
  13. spatialwb

    spatialwb

    Joined:
    Sep 26, 2019
    Posts:
    12
    .net 6.0 is the only version that seems to work with VSCode on M1 Macs btw. Opening unity projects with that setup makes omnisharp not work, meaning you don't get any good intellisense
     
    raining_day0513 and KinanGH like this.
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    This might be unrelated to .NET 6 support in Unity itself. Does Omnisharp work in general on M1 macs? Or is this somehow specific to Unity?
     
  15. spatialwb

    spatialwb

    Joined:
    Sep 26, 2019
    Posts:
    12
    Omnisharp only seems to work with .NET 6 in VSCode. Unity creates projects that target framework v4.7.1, which does not exist in .NET 6, so vscode (omnisharp) spits out an error like:

    Code (CSharp):
    1. [fail]: OmniSharp.MSBuild.ProjectLoader
    2.         This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).
    3. [warn]: OmniSharp.MSBuild.ProjectManager
    4.         Failed to load project file 'XXXX.csproj'.
    If I install .NET 5 on my mac M1, vscode tells me it is not installed (because, from what I can tell, .NET 5 does not support M1)

    So unfortunately, it seems like I cannot use VSCode for development on a mac M1. I have to use Visual Studio for Mac instead.

    This isn't a unity issue for sure, it's likely a vscode/omnisharp issue, but I posted here to give another reason to support NET 6
     
    raining_day0513 likes this.
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks for the details - we don't expect to target .NET 6 in Unity soon. We are working on it though - see the link above for some details.
     
  17. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,066
    OmniSharp on macOS/Linux uses Mono and contains a bundled version of Mono that is not compatible with Unity. I don't think it matters what version of .Net you have installed.

    In the official VSCode documentation on Unity Development with VS Code, it says:
    And in the known issues for OmniSharp-VSCode:
    So make sure you install mono and set useGlobalMono in VSCode to always.

    Though I don't have an Apple Silicon machine, so I don't know if there are any specific issues but I've read that it should work with Rosetta.
     
  18. Antares_

    Antares_

    Joined:
    Oct 19, 2017
    Posts:
    4
    UP
     
    Qbit86 likes this.
  19. dathemon

    dathemon

    Joined:
    Sep 11, 2020
    Posts:
    1
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
  21. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    Bump....

    The 2022.2 alpha build 13 has .NET Standard 2.1 support. This means we should be able to create a NET 6 compatible project. Despite the latest Unity build, it's still generating .NET Framework 4.7.1 targeted project files, even though I specify in the player that I want to use NET Standard 2.1.

    If the bottleneck is Mono, how do I workaround that to create a VS 2022 Unity project that works with NET 6?
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    This is not quite correct. You can create a project that uses .NET Standard 2.1 (although there may be some bug happening here preventing that). But that does not mean the project will have access to .NET 6 APIs. Unity does not yet support .NET 6.
     
  23. raining_day0513

    raining_day0513

    Joined:
    Dec 3, 2019
    Posts:
    9
    Is it possible to run Unity with .NET 6 but with Mono as runtime?
     
    Antares_ and b_bishop like this.
  24. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    That was my impression... They do have a fork of mono that appears to be working towards .NET 6 or CoreCLR integration, but as you can see from my previous posts around here I've failed to gather any instructions on to set it up with the current alpha. I've asked both, is this the mono being used on the current alpha? and, if not what do I need to do to in order use the unity forked mono with the current alpha?

    Both questions have been left unanswered, with Josh's blanket statement of 'Unity does not yet support .NET 6', it seems he's not interested in allowing developers to test the alpha NET 6 or CoreCLR integrations yet... Why not is beyond me, considering Stride (aka Xenko) game engine doesn't seem to be struggling at all with this and already have full C# 9 support...

    It's been 2 years and Unity is still lagging behind. If it doesn't take shape on the next couple alpha builds then I'm giving up on Unity altogether.
     
    raining_day0513 likes this.
  25. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,066
    That's what you'll have to do then.

    I don't know where you've got the notion that some support for .Net 6 should already be in Unity. Microsoft won't update mono to support .Net 6 and I don't see why Unity would, since they are moving over to CoreCLR.

    .Net 6 support is tied to the switch to CoreCLR, so you'll won't see support before the switch and that'll happen in 2023 at the earliest (Josh mentioned that they didn't make it for 2023.1).
     
    b_bishop likes this.
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Sorry for leaving your questions unanswered, I did not intend to do that.

    To be more specific, Unity uses a fork of Mono from https://github.com/mono/mono. This version of Mono is in maintenance mode from Microsoft and does not support .NET 6. We've decided at Unity that the path to .NET 6 support is better done via CoreCLR rather than Mono, so that is the path we are taking.
     
    b_bishop likes this.
  27. Domen_Ptic

    Domen_Ptic

    Joined:
    Jan 18, 2018
    Posts:
    2
    Hey @JoshPeterson,
    just want to ask if there are any news on the Unity nuget packege support :)?
     
  28. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Domen_Ptic, Qbit86 and JesOb like this.
  29. najaa3d

    najaa3d

    Joined:
    Jan 22, 2022
    Posts:
    29
    Any update on the planned "blog" yet?
     
  30. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938