use*_*240 7 powershell tfs powershell-2.0 tfs2010
我只想查看powershell的路径,并在一分钟后在Team Foundation Server上检查此路径.
我怎样才能做到这一点?
我在我的服务器上安装了tfs电源工具.
您不需要电动工具.只需使用Visual Studio随TFS Team Explorer附带的tf.exe命令行util. tf edit <file> /noprompt检查并tf checkin <file> /comment:$comment /noprompt签入.查看tf.exe上的命令行用法以获取更多信息tf /?和tf checkin /?.您需要使用tf.exe的路径配置PowerShell会话.这通常由VS vars批处理文件完成.但你应该能够简单地添加到这样的路径:$PATH += "${VS110COMNTOOLS}..\Ide".
这是一个函数,它将检查是否安装了snapin.如果您安装了powertools,它会使用它,否则,它会使用命令行工具tf.exe
function checkout-file([string] $file)
{
"Checking out $file"
if ((Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue
if ((Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
#try to check out the code using command line tf.exe
&"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe" checkout $file | Out-Null
}
else{
#checkout the file using snapin
Add-TfsPendingChange -Edit $file | Out-Null
}
}else{
#checkout the file using snapin
Add-TfsPendingChange -Edit $file | Out-Null
}
}
Run Code Online (Sandbox Code Playgroud)