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

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

By “Unity projects”, do you mean the .csproj files generated by Unity, or the compilation of the C# code done in the Unity editor?

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

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.