Unity 2018.3 + Visual Studio 2015 -> Invalid "latest" for /langversion

Hi everyone!

I am trying to upgrade our version of Unity for our project and the last error I get is about the language version of the csproj.
I know I can override by hand the version to something that visual studio does understand but is there a way to avoid all our company to do that several time per day?
Did I miss a configuration somewhere?


For the record, here is the error:

Error	CS1617:	Invalid option 'latest' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 6.	    

Thanks for the help!

Florian.

P.S. I have looked at :

https://forum.unity.com/threads/langversion-latest-langversion-is-not-recognized-by-visual-studio.579697/
But I don’t understand how they got around the error…

I found a workaround, but credits goes to visual studio - How to enable c# 7 features on Unity3D projects - Stack Overflow )


Copy & paste this into a file as Assets/Editor/FixProjectVersion.cs :

#if ENABLE_VSTU

using SyntaxTree.VisualStudio.Unity.Bridge;
using UnityEditor;

// Adapted from https://stackoverflow.com/questions/45578298/how-to-enable-c-sharp-7-features-on-unity3d-projects
[InitializeOnLoad]
public class ProjectFilesGeneration
{
	static ProjectFilesGeneration ()
	{
		ProjectFilesGenerator.ProjectFileGeneration += ( string name, string content ) =>
		{
			return content.Replace
			(	"<LangVersion>latest</LangVersion>",
				"<LangVersion>6</LangVersion>" );
		};
	}
}

#endif