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

Getting started with a .NET 6.0 project in latest Alpha 2022.2.a13 is impossible?

Discussion in 'Experimental Scripting Previews' started by b_bishop, May 17, 2022.

  1. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    I'm trying to get started with a prototype that uses the latest C# language features and .NET 6 SDK, so I installed Unity 2022.2 Alpha 13 and was disappointed to learn that my VS project file still generates with a 'TargetFrameworkVersion' of 4.7.1...

    I'm assuming that this is because the Mono bundled with 2022.2 Alpha 13 does not include the Unity Mono fork that supports .NET 6.0?

    What do I need to do in order to upgrade my copy of 2022.2 Alpha 13 with the latest Unity Mono fork?

    If this is not the solution to achieve what I'm after, then what is?

    I've read all the threads on here and I'm still confused what the current state of 2022.2 Alpha 13 is for .NET 6 integration... Documentation on how this is meant to work is virtually non existent for the alpha, so I don't understand how you expect developers to test .NET 5 & 6 runtimes/features.

    Is .NET 6 features only working for Il2Cpp at the moment?

    If the Unity Mono fork does not currently support .NET 6, then how do I replace it with CoreCLR so I CAN use .NET 6?

    My end goal is that my CS Proj file generated by this alpha build should show a Language Version of 10.0 and a TargetFramework of NET Standard 2.1, or Net 6.0, NOT 4.7.1...

    There needs to be a serious documentation task that addresses this, either by creating an instructional thread on the Alpha build forum / this forum and linking it in the Mono Upgrade manual.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,926
    I'm sorry that you are experiencing these issues. However, Unity at 2022.2 alpha does not support .NET 6 as a build target. So it is not possible to accomplish what you are attempting.

    You can select ".NET Standard" as the API Compatibility Level option, in which case you will get access to the .NET Standard 2.1 API.

    You can find more details about Unity's plans for .NET 6 (and later) support in a GDC talk posted in this thread: https://forum.unity.com/threads/gdc-2022-the-future-of-net-and-unity.1255956/

    We have not yet discussed release dates for this support though.
     
    b_bishop likes this.
  3. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    Even when I select .NET Standard, for the 2.1 API, the CSProj file generated will still have a TargetFrameworkVersion of 4.7.x.. So, am I misunderstanding how something works here?

    Why is it that the build target cannot be changed to 5 or 6 for Unity?

    I'm not sure how important TargetFrameworkVersion for a Unity CSProj file?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,926
    Make sure that you have the latest version of the Code Editor for Visual Studio package installed with the Unity project: https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/manual/index.html. I believe that it generates the .csproj files.

    Moving the Unity ecosystem to .NET 5 or 6 is a bit of a long process. You can watch the talk I linked to or check on this ongoing mega-thread for many more details: https://forum.unity.com/threads/unity-future-net-development-status.1092205/
     
  5. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    So I did as described in the manual for Unity, then I checked the project file produced by Unity and the TargetFrameworkVersion remains the same still, as NET Framework 4.7!

    Shouldn't the generator be creating a .NET Standard 2.1 project file?

    I've read a lot and understand you're hard at work upgrading to .NET 6+ and I want to know how I can create a barebones .NET Standard 2.1 project..
     
    Last edited: May 17, 2022
  6. b_bishop

    b_bishop

    Joined:
    May 17, 2022
    Posts:
    7
    I should add that I have tried manually setting the framework by replacing the <TargetFrameworkVersion> with a <TargetFramework> element instead, and put in the value Net Standard 2.1 -- I have no idea how this is suppose to work, can you please provide guidance on what the expectations are here??

    Also, I created an issue to track the documentation needed on VS side:
    https://github.com/MicrosoftDocs/visualstudio-docs/issues/8027
     
    Last edited: May 17, 2022
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,926
    I think it should generate a .NET Standard 2.1 project. Can you submit a bug report to Unity for this?

    https://unity3d.com/unity/qa/bug-reporting
     
  8. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Harry-Wells likes this.
  9. FoodFish_

    FoodFish_

    Joined:
    May 3, 2018
    Posts:
    58
    Any news on the support for .Net5, .Net 6?
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,926
    FoodFish_ likes this.