将 XAML 升级模板与 TFS 2015 \ 2017 结合使用



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

运行生成时,由于核心程序集中引入了一些重大更改,因此会出现此错误。XAML 版本已被弃用一段时间...和旧的基于 MSBuild 的团队构建已不再支持。所以Microsoft(理所当然地)不在乎。

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

C:Program Files (x86)MSBuildMicrosoftVisualStudioTeamBuildMicrosoft.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)MSBuildMicrosoftVisualStudioTeamBuildMicrosoft.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()

如果不关心将代码标记为生成过程的一部分或更新关联的工作项,则可以解决此错误。就我而言,我仍在使用 UpgradeTemplate 作为一种方便的方式,在 TFVC 中对构建计算机上的构建文件夹执行基于签入的源代码"获取最新"......根本不是真正的"构建"。所以这是A-OK。

在 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>

最新更新