Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  5. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

How do you change the target C# version for Visual Studio?

Discussion in '2018.3 Beta' started by OFFICIAL_bryanw, Dec 11, 2018.

  1. OFFICIAL_bryanw

    OFFICIAL_bryanw

    Joined:
    Jul 6, 2018
    Posts:
    36
    Hey All,

    I recently imported a package that uses C# 7.2 features, but my Unity projects all default to C# 7.0. I'm using the 4.x runtime equivalent and I'm on Unity 2018.3.0b12

    Cheers,
    Bryan
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,306
    By "Unity projects", do you mean the .csproj files generated by Unity, or the compilation of the C# code done in the Unity editor?
     
  3. OFFICIAL_bryanw

    OFFICIAL_bryanw

    Joined:
    Jul 6, 2018
    Posts:
    36
    The csproj's themselves. Right now it defaults to C#7 so when I try to debug my code the compilation fails when C#7.2 features are in the source

    I can manually change them myself but it ends up being pretty tedious
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,306
    At the moment, I think the geneated .csproj files specify the C# language version should be "latest". Is that what you see as well?

    That means Visual Studio will use the latest C# version Roslyn supports on your machine. Often you can work around this by updating to the latest version of Visual Studio.

    Longer term, we're working on changes now to emit the .csproj so that it uses the Roslyn version Unity ships with, which means it will use the exact same compiler and C# version Unity does, which is the correct solution.