TFS 2013 构建 .NET 4.6 / C# 6.0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32659106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:43:15  来源:igfitidea点击:

TFS 2013 building .NET 4.6 / C# 6.0

.nettfsbuildc#-6.0.net-4.6

提问by zimdanen

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.

我们使用 TFS 2013 作为我们的构建服务器。我已经开始了一个 C# 6.0 项目,我正在尝试构建它。我正在使用新的空条件运算符,并且我的构建窒息。我试过在 TFS 服务器上安装一些东西,包括目标包和 VS 2015。我试过为 MSBuild 参数提供 /tv:14.0。

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

Configuration\EntityEntityConfig.cs (270):无效的表达式术语“.”
Configuration\EntityEntityConfig.cs (283):无效的表达式术语“.”
Configuration\EntityEntityConfig.cs (283):语法错误,“:”预期
......等。

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

在这一点上,我不知道还能尝试什么。任何建议将不胜感激。

回答by Marson

People using TFS 2012 have reported success using:

使用 TFS 2012 的人已经报告成功使用:

/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.

作为 MSBuild 的参数。也许这可能对你有用,但到目前为止这对我的 TFS 2013 构建代理不起作用。

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

更新:我终于让它在 TFS 2013 上工作了。这是我必须做的:

  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.0I did not have to use the other two I mentioned above.
  1. 安装 VS 2015 或Microsoft Build Tools 2015(我都有)。
  2. 编辑我的构建以使用名为TfvcTemplate.12.xaml的构建过程模板。我想任何比这个更新的模板都可以,但 DefaultTemplate.11.1.xaml 肯定不起作用!)
  3. 将 MSBuild 参数设置为/tv:14.0我不必使用我上面提到的其他两个。

回答by Vicky - MSFT

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

似乎 /tv:14.0 命令参数没有按预期工作。请参阅: BuildActivity 忽略 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 ProjectMSBuild 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.
  1. 在 Visual Studio 中打开模板并找到Run MSBuild for ProjectMSBuild 活动。
  2. 将工具版本设置为“14.0”。
  3. 将 ToolPath 设置为以 MSBuild14 为目标(默认情况下:“C:\Program Files (x86)\MSBuild\14.0\Bin”)。
  4. 签入此构建过程模板并重新排队构建。

回答by Jim Roth

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.

如果您选择在构建机器上安装 VS 2015,有一个重要步骤:首次使用时打开它,并确保它已获得许可。否则,您将继续遇到构建失败。

回答by Kostas Xagoraris

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").

如果您运行 DefaultTempalte.11.1.xaml 然后找到 msbuild 活动(此模板中有 2 个活动,它们的标签是“为项目运行 MSBuild”)并将 ToolPath 属性更改为 msbuild 工具集的路径(对我来说是“ C:\Program Files (x86)\MSBuild\14.0\Bin”)。

Nothing else is necessary.

没有其他必要。

回答by Daniel Carvalho Liedke

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

如果使用UpgradeTemplate.xml,则只需更改“Run TfsBuild for Configuration Folder”:

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

1.将 ToolPath 设置为以 MSBuild14 为目标(默认情况下:“C:\Program Files (x86)\MSBuild\14.0\Bin”)。

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

2.签入此构建过程模板并重新排队构建。

Thanks!

谢谢!

回答by Steztric

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.

构建过程决定了您使用的构建工具版本。vanilla 构建定义使用“DefaultTemplate.11.1.xaml”构建过程模板,该模板被配置为使用 Build Tools 2013。

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

解决此问题的最快方法是简单地切换到“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

如果要修改默认模板,则需要从 $/[Project]/BuildProcessTemplates/DefaultTemplate.11.1.xaml 中检出,然后编辑 Arguments 以设置 BuildProcessVersion

Edit Build Process Version

编辑构建过程版本