有没有办法找出映射到现有tfs工作区的特定文件夹是否为local workspace or a server workspace?如何发现TFS工作区是本地还是服务器工作区
我大多使用tf.exe
命令或powershell
甚至API答案兴趣(但不与GUI!)。
有没有办法找出映射到现有tfs工作区的特定文件夹是否为local workspace or a server workspace?如何发现TFS工作区是本地还是服务器工作区
我大多使用tf.exe
命令或powershell
甚至API答案兴趣(但不与GUI!)。
经过长时间的搜索(在非常糟糕的msdn文档中关于tf.exe
命令的小时和小时!),我找到了获取信息的方法!
首先,您必须使用tf.exe workfold c:\your\path
命令找出文件夹位于哪个工作区中。该命令的输出类似的东西:
================================================================
Workspace : NameOfYourWorkspace (John Doe)
Collection: https://tfs.yourtfs.com/tfs/defaultcollection
$/: C:\your\path
然后你要提取“工作区”(注:我们真的不知道为什么这里的tf.exe
命令被全球接受的格式不输出工作区tf.exe
命令即“工作区名;所有者”,因此应适应)和“收集”的数据在tf.exe workspaces /format:detailed
命令来使用它,这样的:
tf.exe" workspaces /format:detailed /collection:"https://tfs.yourtfs.com/tfs/defaultcollection" "NameOfYourWorkspace;John Doe"
命令输出类似的东西:
===============================================
Workspace : NameOfYourWorkspace
Owner : John Doe
Computer : YOU_COMPUTER
Comment :
Collection : yourtfs.com\DefaultCollection
Permissions: Private
Location : Local
File Time : Current
Working folders:
$/: C:\your\path
!
,我想这里最重要的数据是
我已经写了一个小PowerShell脚本Location : Local
(或Server
),如果它可能是没有多大用处的人来提取数据在输出使用它们:
function ExtractData($text, $key)
{
$pattern = "^$key *: *(.+)$"
$filteredText= $text | Select-String $key
$found = $filteredText -match $pattern
if ($found) {
return $matches[1]
}
exit 1
}
$currentWorkspaceData = (& "$env:VS120COMNTOOLS..\IDE\tf.exe" workfold .)
$workspace = ExtractData $currentWorkspaceData "Workspace"
$found = $workspace -match "^(.+) \((.+)\)$"
if (!$found) {
exit 1
}
$workspace = $matches[1] + ";" + $matches[2]
$collection = ExtractData $currentWorkspaceData "Collection"
$location=(ExtractData (& "$env:VS120COMNTOOLS..\IDE\tf.exe" workspaces /format:detailed /collection:$collection $workspace) "Location")
$localServer = $location -eq "Local"
if($localServer)
{
Write-Host "Local!!!"
}
else
{
Write-Host "Server!!!"
}
该脚本只给出当前文件夹的答案,但可以很容易地适应...