我们已经实现了 TFGet 来下载最新的项目,给出 TFS URL、TFS 路径和本地路径。
如果在构建定义时选择了搁置集,则需要实现代码以取消搁置搁置集的详细信息。
ItemSet = VcsRef.GetItems(TfsPath, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.File,true);
-- 如果它是一个文件夹,则使用它来获取用于下载文件/创建文件夹的项目列表。
要使用此下载搁置集详细信息,
PendingSet[] pendingSets = VcsRef.QueryShelvedChanges("tfget", "userid", null, true);
if (shelvedChanges.Length == 0)
{
Console.Error.WriteLine("You don't have permission to any of the files involved.");
Environment.Exit(1);
}
else if (pendingSets.Length > 1)
{
Console.Error.WriteLine("More than one shelveset matched.");
Environment.Exit(1);
}
PendingChange[] shelvedChanges = pendingSets[0].PendingChanges;
if (pendingSets.Length == 0)
{
Console.Error.WriteLine("No shelveset matched.");
Environment.Exit(1);
}
foreach (PendingChange shelvedChange in shelvedChanges)
{
// We only want files that are being edited, but there's nothing to diff if
// the file is guaranteed not to exist at a different version.
Console.WriteLine("shelved changes are",shelvedChange.ToString());
if (shelvedChange.ItemType != ItemType.File ||
!shelvedChange.IsEdit || shelvedChange.IsAdd || shelvedChange.IsBranch)
{
continue;
}
var relativeNameOnly = shelvedChange.ToString().Remove(0, TfsPath.Length);
var targetName = Local + relativeNameOnly.Replace("/", @"\");
//Console.WriteLine("shelvedChange {0} is", shelvedChange);
shelvedChange.DownloadShelvedFile(targetName);
}
但是无法下载,这是正确的方法吗?