PowerTools Update-TfsWorkspace没有最新版本

时间:2016-04-19 16:27:02

标签: powershell tfs tfs-power-tools

我尝试使用PowerTools Update-TfsWorkspace,正如标题所示,它不起作用。

示例,我有一个同事检查$ / Contoso / Dev / Test中的文件。在源代码管理中,我可以看到它显示为灰色,表示虽然它在那里,但我没有下载它。所以我做了以下几点。

C:\TFS\Contoso\Dev> Update-TfsWorkspace -All -Overwrite -Force -Recurse -Item .\Test

该命令立即执行,不执行任何操作。没有错误输出或任何东西。并且它没有最新。如果我进入VS源代码管理并手动获取最新版本,它会抓取目标文件,但理想情况下它应该告诉我所有文件都是最新的。有没有人使用此cmdlet或使用PowerTools从Powershell执行获取最新操作?

1 个答案:

答案 0 :(得分:2)

Update-TfsWorkspace应该在powershell脚本或powershell cmdlet中使用。如果您有多个工作区,则可能无效。

尝试以下方法:

$tfsCredential = Get-Credential;
$tfsServer = Get-TfsServer -Name "https://tfs.xxx.com:443/tfs/teamproject" -Credential $tfsCredential;;
$tfsws = Get-TfsWorkspace -Server $tfsServer -Computer $hostname -Owner $tfsCredential.UserName;
$tfsPath = $tfsws.GetServerItemForLocalItem($filename);
$prop = Get-TfsItemProperty -Item $tfsPath -Server $tfsServer -Workspace $script:tfsws;
$tfsws.Get(@($tfsPath), [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Parse($prop.VersionLatest,     $script:tfsws.OwnerName)[0], [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full, [Microsoft.TeamFoundation.VersionControl.Client.GetOptions]::None)

此外,要更新工作区,您可以直接使用tf get command。如:

C:\TFS\Contoso\Dev> tf get itemspec .\Test /noprompt