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

C# Compiler Unity setup Net 4.6 loosing VS2017 Unity coding behavior. (2018.2.b01)

Discussion in 'Experimental Scripting Previews' started by Quatum1000, Apr 22, 2018.

  1. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi,

    on targeting .Net 4.6 in Unity editor, VS 2017 ask to change the c# project to .Net 4.6/7 as well.
    But after targeting VS2017 it loose the unity integration coding behavior completely.

    * Is there the unity integration for VS2017 .Net4.6 available already, that works in the same way like Net 3.5?
    * When ignoring the new setting for Net 4.6 in VS2107, does this have any quirky behavior to the compiler code unity execute? Or does VS2017 compile to .Net 3.5 anyway?

    * Does anyone know how to change back from VS2017 .Net4,7 to .Net 3.5 including the existing unity integration and without deleting all VS related files and folders in the project? Targeting back to .Net 3.5 in unity does not change/ask to set back VS2017 to the existing unity integration.

    Thank you..
     
    Last edited: Apr 22, 2018
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    The integration of VS 2017 and Unity should be working for both the .NET 4.x equivalent runtime and the .NET 3.5 equivalent runtime in Unity.

    First, please make sure that you have the latest version of Visual Studio Tools for Unity installed in Visual Studio 2017. You can check this with Help > About in Visual Studio.

    Second, when you initially open a project with the .NET 4.x runtime (set in Unity), then Visual Studio should ask you to install the .NET 4.7.1 targeting pack. It sounds like this is the first thing you encountered. Installing that should not have any impact on the behavior with the .NET 3.5 equivalent runtime in Unity. In other words, changing the scripting runtime in Unity back to the old one should not require any changes in Visual Studio. Things should "just work" :).

    We can investigate more though if that is not the case.
     
  3. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Last edited: Apr 23, 2018
  4. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    I have updated VS2017 to the latest version including the Unity Integration 3.6.xx. Targeting Unity 2017 to 4.6.

    Open VS2017 through Unity 2017 ask me:
    Untitled-1.jpg


    I went to : https://www.microsoft.com/net/download/visual-studio-sdks and installed the 4.7.1 run-time.
    The result is the same message (see above), after open any script with VS2017.

    Then try to install by the VS Installer: Untitled-2.jpg

    Same message again (see above), after open any script with VS2017.

    And editing in unity is impossible because compiler directives are not recognized.
    VS2017 told me Net4.6 is not installed.

    Any ideas how to solve this in VS2017?

    Edit: Unfortunately now Mono develop opens after targeting 4.6 in VS. This is really annoying.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Ugh, it looks like something is really mixed up.

    I think this is the proper version for VS 2017. I'm using VSTU 3.6.0.5 with VS 2017 without issues.

    Which version of Unity are you using? Initially, I thought you were using Unity 2018.2b1, but then you mentioned Unity 2017.

    Unity 2018.2b1 should be targeting .NET 4.7.1. Earlier versions of Unity should target .NET 4.6.1 - which seems to be the behavior you see.

    We should be able to sort this out though.

    Edit: I should have said: "Earlier versions of Unity should target .NET 4.6", not .NET 4.6.1. Sorry about that.
     
    Last edited: Apr 23, 2018
  6. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Hello,

    First regarding Visual Studio and Visual Studio Tools for Unity:
    For Visual Studio 2017: no need to go to the gallery, VSTU 2017 is part of the VS2017 installation, bundled with the Unity workload that you can install directly from the VS installer.

    For previous version indeed, like VS2015, it was mandatory to install the extension from the gallery.

    Regarding targeting packs, as Josh explained, Unity 2018.2b1 should be targeting .NET 4.7.1. Earlier versions of Unity should target .NET 4.6.

    So double check that both .NET Targeting Packs 4.6 and 4.7.1 are properly installed in your Visual Studio 2017 installation:

    upload_2018-4-23_10-24-47.png

    You should never change the targeting in your projects, because the project file will be re-generated. It's mandatory to fix this issue if you want to keep a proper integration between Unity and VS.

    Thanks
    Sebastien Lebreton [MSFT]
     
  7. Atabek

    Atabek

    Joined:
    Oct 27, 2014
    Posts:
    3
    After switching back to net3.5. Close Unity. Delete all .csproj and .sln files. Start unity open any script. After vs2017 starts in the right top bar -> Solution explorer -> right click each solution and click refresh.
     
    dylanfries likes this.
  8. dylanfries

    dylanfries

    Joined:
    Jul 11, 2012
    Posts:
    16
    I had this issue and all my builds were giving me a console. I was able to force refresh by changing Target Platform Architecture to x86 then back to x86_64.