退房手续从2010年TFS文件使用PowerShell(Check-Out files from T

2019-08-03 12:01发布

我只是想看看使用PowerShell的路径,并检查在这条道路一分钟后在Team Foundation Server中。

我怎样才能做到这一点?

我已经安装了TFS电动工具在我的服务器。

Answer 1:

你不需要的电动工具。 只需使用tf.exe命令生产线使用率随Visual Studio和TFS团队资源管理器。 tf edit <file> /noprompt退房和tf checkin <file> /comment:$comment /noprompt 。在检查只看tf.exe的命令行用法的更多信息tf /?tf checkin /? 。 您将需要一起tf.exe路径配置PowerShell会话。 这通常是由VS瓦尔批处理文件来完成。 但是,你应该能够简单地添加到路径,像这样: $PATH += "${VS110COMNTOOLS}..\Ide"



Answer 2:

这里是一个将检查是否安装了管理单元的功能。 如果你安装了电动工具,它使用的,否则,它使用命令行工具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
    }
}


Answer 3:

如果您已经安装了PowerShell中的电动工具命令行开关。 像Kieth提到,在命令行开关别名TF为全tf.exe路径的一部分,你并不需要的路径。 所以,简单地使用tf.exe命令行参考这里 ,所有的这些,如果你有正确安装PowerShell的命令行开关应该工作。

你应该确保你的PowerShell有他们虽然通过使用该命令安装

 Add-PSSnapin Microsoft.TeamFoundation.PowerShell


Answer 4:

这是我的解决方案:

$tf = &"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe"     checkout C:\setup\folder /recursive
$tf | Out-null


Answer 5:

另一种选择是,如果你想处理在同一命令多个文件,无需拿起其他文件或遍历他们使用的外卡。

   tf.exe undo AssemblyInfo* /recursive
   tf.exe checkout AssemblyInfo* /recursive
   #changes files
   tf.exe checkin AssemblyInfo* /recursive


文章来源: Check-Out files from TFS 2010 with powershell