首页 > 解决方案 > 将 XAML UpgradeTemplate 与 TFS 2015 \ 2017 一起使用

问题描述

我从 TFS 2013 升级到 2017 时遇到了这个问题。如果您仍在使用 UpgradeTemplate.xaml 运行旧的 TFS 2005\2008 风格的 MSBuild Team Builds (TFSBuild.proj),您会发现它们不适用于 TFS 2015 或2017 XAML 构建代理。

由于核心程序集中引入了一些重大更改,您将在运行构建时收到此错误。XAML 构建已被弃用一段时间......并且旧的基于 MSBuild 的团队构建已失去支持。所以微软(理所当然地)不在乎。

但是有没有办法让这些构建在 TFS 2015\2017 中工作?将这些转换为使用 XAML 构建,然后在升级到 TFS 2017 后将它们转换为新的构建引擎,这将浪费大量时间。

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (957): The following errors were encountered while processing the workflow tree:
'VisualBasicValue<LabelChildOption>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.LabelChildOption.Fail".
'LabelChildOption' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.

'VisualBasicValue<RecursionType>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.RecursionType.Full".
'RecursionType' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.

 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (957): The "Label" task failed unexpectedly.
System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
'VisualBasicValue<LabelChildOption>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.LabelChildOption.Fail".
'LabelChildOption' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.

'VisualBasicValue<RecursionType>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.RecursionType.Full".
'RecursionType' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.

   at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
   at System.Activities.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager extensionManager)
   at System.Activities.WorkflowApplication.EnsureInitialized()
   at System.Activities.WorkflowApplication.RunInstance(WorkflowApplication instance)
   at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary`2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout)
   at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary`2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions)
   at Microsoft.TeamFoundation.Build.Tasks.WorkflowTask.ExecuteInternal()
   at Microsoft.TeamFoundation.Build.Tasks.Task.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

标签: xamltfsbuild

解决方案


如果您不关心将代码标记为构建过程的一部分或更新关联的工作项,则可以解决此错误。在我的情况下,我仍然使用 UpgradeTemplate 作为一种便捷的方式,将 TFVC 中的源代码基于“获取最新”签入到构建机器上的构建文件夹中……根本不是真正的“构建”。所以这很好。

在 TFSBuild.proj 中将这两个属性设置为 true

这将导致 MSBuild 跳过执行 CoreLabel 和 CoreGetChangesetsAndUpdateWorkItems 目标。CoreLabel 是加载构建失败的任务的任务......并且 CoreGetChangesetsAndUpdateWorkItems 需要标签存在,否则它也会失败。

我通过挖掘旧的 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets 找到了这些属性 - 这是 TFS 2005 \ 2008 附带的团队构建脚本。

<SkipLabel>true</SkipLabel>  

<SkipGetChangesetsAndUpdateWorkItems>true</SkipGetChangesetsAndUpdateWorkItems>

推荐阅读