下圖是在VS2010里創(chuàng)建Label的界面

可以看出創(chuàng)建Label 需要如下參數(shù):Name、Comment、Path、Version 。下面是代碼實(shí)現(xiàn):
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;//創(chuàng)建標(biāo)簽string labelName = "標(biāo)簽名稱";string labelComment = "標(biāo)簽評(píng)論";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);//查詢標(biāo)簽VersionControlLabel[] lbls = versionControl.QueryLabels(null, null, null, true);//查詢?nèi)繕?biāo)簽//VersionControlLabel[] lbls = version.QueryLabels(null, null, null, false, path, VersionSpec.Latest);// 查詢指定路徑的標(biāo)簽//刪除標(biāo)簽versionControl.DeleteLabel(lbls[0].Name, lbls[0].Scope);
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注