C# Language Version


I've got a build server/agent (v9.1.6) and I'm trying to build a C# project with the language version explicitly set to C# 6.0.  The associated Build Step is Visual Studio (sln) and the Visual Studio property is set to Microsoft Visual Studio 2015.  The build log then shows:

Step 2/6: Visual Studio (sln)
  [Step 2/6] Solution.sln.teamcity: Build target: TeamCity_Generated_Build
    [Solution.sln.teamcity] TeamCity_Generated_Build
      [TeamCity_Generated_Build] MSBuild
        [MSBuild] Solution.sln: Build targets: Build
          [Solution.sln] Build
            [Build] MSBuild
              [MSBuild] Folder\Project.csproj: Build default targets
                [Folder\Project.csproj] CoreCompile
                  [CoreCompile] Csc
                    [Csc] C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe ... /langversion:5 ...

What part of the tool chain is responsible for setting that langversion option?  How can I ensure VS'15 builds use C# 6.0 by default?


Hello Chris,

Do you have <LangVersion> element specified in the csproj file? See this post for more details.


Yes, well, sort of.  I just found the issue.  It was set to 6 in the Debug configuration, but still set to 5 in the Release configuration.  If I had a dollar for every time...


Please sign in to leave a comment.