什么';使用TFS API向文件添加标签的最佳方法是什么?
我想使用TFSAPI向一组文件添加一个标签。我的代码如下所示:什么';使用TFS API向文件添加标签的最佳方法是什么?,tfs,Tfs,我想使用TFSAPI向一组文件添加一个标签。我的代码如下所示: VersionControlLabel label = new VersionControlLabel(this.vcServer, this.label, this.vcServer.AuthenticatedUser, this.labelScopeDirectory, this.labelComment); List<LabelItemSpec> label
VersionControlLabel label = new VersionControlLabel(this.vcServer, this.label,
this.vcServer.AuthenticatedUser, this.labelScopeDirectory, this.labelComment);
List<LabelItemSpec> labelSpecs = new List<LabelItemSpec>();
// iterate files and versions
foreach (var fileAndVersion in this.filesAndVersions)
{
VersionSpec vs = null;
Item i = null;
// i have no idea why the itemspec is needed instead of the item and version...
ItemSpec iSpec = new ItemSpec("{0}/{1}".FormatString(this.source, fileAndVersion.Key), RecursionType.None);
GetItemAndVersionSpec(fileAndVersion.Key, fileAndVersion.Value, out vs, out i);
labelSpecs.Add(new LabelItemSpec(iSpec, vs, false));
}
this.vcServer.CreateLabel(label, labelSpecs.ToArray(), LabelChildOption.Merge);
所以MSDN告诉我不要使用枚举(LabelChildOption),这是创建标签并将其添加到文件的唯一方法
有更好的办法吗?在TFS API中,这是一个“灰色”区域吗
//我不知道为什么需要itemspec而不是item和version
ItemSpec包含递归类型。如果您事先知道要标记文件夹的所有子文件夹(1级,或完全递归到所有子文件夹),则可以使用ItemSpec大大压缩将传递给服务器的LabelItemSpec[]的大小(&R)
在TFS API中,这是一个“灰色”区域吗
不是灰色的,只是记录不清。标签在TFS中是事后才想到的;它们在管理SDLC的“Microsoft方式”中不起任何作用,因此在指南中根本没有提到它们。据我所知,它们主要是为了功能完整性(又称竞争分析)。它们还可以方便地进行一些复杂的一次性数据库操作,否则客户端API将无法进行这些操作
请阅读MSDN文章下方“社区内容”部分中Buck Hodges的解释——这是重要的部分。“替换”通常比“合并”更接近人们想要的,但如果你确定你正在创建一个全新的标签,那么这并不重要
This enumeration supports the .NET Framework infrastructure
and is not intended to be used directly from your code.