TFS 2013 building .NET 4.6 / C# 6.0

2019-01-03 06:36发布

We use TFS 2013 to as our build server. I've started a C# 6.0 project and I am trying to get it to build. I am using the new null-conditional operators, and my build chokes. I've tried installing several things on the TFS server, including the targeting pack and VS 2015. I've tried providing /tv:14.0 to the MSBuild arguments.

Configuration\EntityEntityConfig.cs (270): Invalid expression term '.'
Configuration\EntityEntityConfig.cs (283): Invalid expression term '.'
Configuration\EntityEntityConfig.cs (283): Syntax error, ':' expected
... etc.

At this point, I have no idea what else to try. Any suggestions would be greatly appreciated.

6条回答
神经病院院长
2楼-- · 2019-01-03 06:56

If using UpgradeTemplate.xml then just change the "Run TfsBuild for Configuration Folder":

1.Set ToolPath to target to MSBuild14 (by default: "C:\Program Files (x86)\MSBuild\14.0\Bin").

2.Check in this build process template and re-queue the build.

Thanks!

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-03 07:00

If you choose to install VS 2015 on the build machine, there's an important step: open it for first use, and make sure it's licensed. Otherwise, you'll continue to experience build failures.

查看更多
做个烂人
4楼-- · 2019-01-03 07:04

People using TFS 2012 have reported success using:

/tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:VisualStudioVersion=14.0

as arguments to MSBuild. Perhaps this might work for you, but so far this does not work for my TFS 2013 build agents.

Update: I finally got this to work on TFS 2013. Here is what I had to do:

  1. Install VS 2015 or Microsoft Build Tools 2015 (I have both).
  2. Edit my build to use a build process template called TfvcTemplate.12.xaml. I guess that any template newer than this one will do, but the DefaultTemplate.11.1.xaml definitely won't work!)
  3. Set MSBuild arguments to /tv:14.0 I did not have to use the other two I mentioned above.
查看更多
做自己的国王
5楼-- · 2019-01-03 07:08

It seems that the /tv:14.0 command argument doesn't work as expected. See: BuildActivity ignores ToolsVersion

As a workaround, you need to customize the build process template:

  1. Open the template in Visual Studio and find the Run MSBuild for Project MSBuild activity.
  2. Set ToolVersion to "14.0".
  3. Set ToolPath to target to MSBuild14 (by default: "C:\Program Files (x86)\MSBuild\14.0\Bin").
  4. Check in this build process template and re-queue the build.
查看更多
ら.Afraid
6楼-- · 2019-01-03 07:08

The build process determines what build tools version you are using. A vanilla build definition uses the "DefaultTemplate.11.1.xaml" build process template, which is configured to use Build Tools 2013.

The fastest way to fix this is to simply switch to the "TfvcTemplate.12.xaml"

Select Template

If you want to modify the default template, you will need to check it out from $/[Project]/BuildProcessTemplates/DefaultTemplate.11.1.xaml, then edit the Arguments to set the BuildProcessVersion

Edit Build Process Version

查看更多
三岁会撩人
7楼-- · 2019-01-03 07:15

If you run the DefaultTempalte.11.1.xaml then find the msbuild activity (there are 2 in this template and their label is "Run MSBuild for Project") and change the ToolPath property to the path of the msbuild toolset (for me that was "C:\Program Files (x86)\MSBuild\14.0\Bin").

Nothing else is necessary.

查看更多
登录 后发表回答