首页 > 其他 > 详细

TFS二次开发11——标签(Label)

时间:2014-03-15 21:07:31      阅读:605      评论:0      收藏:0      [点我收藏+]

下图是在VS2010里创建Label的界面

 bubuko.com,布布扣

可以看出创建Label 需要如下参数:Name、Comment、Path、Version 。
下面是代码实现:

bubuko.com,布布扣
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

string tpcURL = "http://127.0.0.1:8080/";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));
VersionControlServer versionControl = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;

//创建标签
string labelName = "标签名称";
string labelComment = "标签评论";
string path = "$/CRM/Branches/WeiMovie";
VersionSpec version = VersionSpec.Latest;
var versionControlLabel = new VersionControlLabel(versionControl, labelName, versionControl.AuthorizedUser, path, labelComment);

//Represents one or more files or folders on the local machine or in the repository.
var itemSpec = new ItemSpec(path, RecursionType.Full);
var labelItemSpec = new LabelItemSpec[1];
labelItemSpec[0] = new LabelItemSpec(itemSpec, version, false);
var lb = versionControl.CreateLabel(versionControlLabel, labelItemSpec, LabelChildOption.Merge);
//查询标签
VersionControlLabel[] lbls = versionControl.QueryLabels(null, null, null, true);//查询全部标签
//VersionControlLabel[] lbls = version.QueryLabels(null, null, null, false, path, VersionSpec.Latest);// 查询指定路径的标签
//删除标签
versionControl.DeleteLabel(lbls[0].Name, lbls[0].Scope); 
bubuko.com,布布扣

 

TFS二次开发11——标签(Label),布布扣,bubuko.com

TFS二次开发11——标签(Label)

原文:http://www.cnblogs.com/xumingxiang/p/3135245.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!