Update-TFSWorkspace不起作用

时间:2013-01-18 21:08:21

标签: powershell tfs

为什么

Update-TfsWorkspace [[-Item] <QualifiedItemSpec[]>] [-All] [-Force] [-Overwrite] [-Recurse] [-Version <String>]

不行吗? 等效的tf.exe在完全相同的文件夹中工作正常:

tf get itemspec [/version:versionspec] [/all] [/overwrite] [/force] [/preview] [/recursive] [/remap] [/noprompt]

使用Win 8。

以下是我正在使用的确切命令:

Update-TfsWorkspace -Item "$/myfilepaht" this does NOT WORK

tf get itemspec "$/myfilepaht" #this WORKS

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题(可能是因为我有多个工作区) 所以我用以下代码解决了它:

$tfsCredential = Get-Credential;
$tfsServer = Get-TfsServer -Name "https://tfs.tools4ever.com:443/tfs/t4edevnet2010" -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)