4

We recently upgraded to TFS 2015 from 2010. As a result of this upgrade, we wanted to start using C# 6 syntax in our projects, but whenever we do, the build fails due to syntax errors. The build agents/controllers are also from the TFS 2015 installer (it's a whole new set of servers)

Our builds are using the TfvcTemplate.12.xaml Process template, which apparently is the TFS2013 xaml build template.

According to this answer, you can modify the template to set the ToolsVersion appropriately, but our template does not have a Run MSBuild for Project item, it has a Run MSBuild activity, which does not have the indicated properties.

I've also tried setting the tv:14.0 and /p:VisualStudioVersion=14.0 arguments on MSBuild from the Build Definition from this answer, but this also does not resolve the issue.

What do we need to do in order to get the build to accept C# 6 syntax?

Community
  • 1
  • 1
Obsidian Phoenix
  • 4,083
  • 1
  • 22
  • 60
  • On my dev machine I had to resset the settings of my Visual Studio. I don't know why. Maybe a Plugin or Add On or caching. –  Sep 15 '16 at 13:38
  • A project's build settings include the target language. You have to change the language version of old projects to C# 6. – Panagiotis Kanavos Sep 15 '16 at 13:57
  • Go to build agent machine, and use MSBuild command to build your project, to see what result you'll get. – Cece Dong - MSFT Sep 16 '16 at 05:24
  • Do you use VS2015 to create C# 6.0 project? – Cece Dong - MSFT Sep 16 '16 at 06:00
  • @Cece-MSFT dammit, this was a PEBKAC, the actual error was from Stylecop.MSBuild, updating the package resolved the issue. Not sure if its worth updating the Q to be more specific, and answer it, or just delete the Question outright? – Obsidian Phoenix Sep 26 '16 at 12:00

1 Answers1

0
  1. If you are using VS 2015, then C# 6 should be working out of the box. Try to create a light c# 6.0 project and queue XAML build to check whether the issue from your project or from build server.

  2. Before using XAML build, make sure you can have successful build with MSBuild command line manually on build agent server.

  3. If you migrate to C# 6.0, check blog Migrating project to .NET 4.6 and C# 6 to see whether it is helpful.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39