使用 Microsoft.TeamFoundation.Client 和 Powershell 从变更集中获取列表文件 [英] Get list files from a changeset using Microsoft.TeamFoundation.Client and Powershell

查看:53
本文介绍了使用 Microsoft.TeamFoundation.Client 和 Powershell 从变更集中获取列表文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一家公司使用 TFS 2008.

I use TFS 2008 in a company.

如何使用 Microsoft.TeamFoundation.ClientPowershell 从 TFS 变更集中获取文件列表?

How can I get list of files from a TFS changeset using Microsoft.TeamFoundation.Client and Powershell ?

我的脚本:

Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"

推荐答案

Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"

$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer) 
$versionControlType = [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer] 
$versionControlServer = $tfs.GetService($versionControlType) 

$latest = [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest
$recursionType = [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full # 'Full'

# If specified, format should be like "Dyyyy-MM-ddThh:mm". 
#.EXAMPLE      C:\Export-TFS-Changes-To-Excel.ps1 -dateFrom D2014-10-20T00:00 -dateTo D2014-10-24T00:00 

$dateFrom = "D2015-03-17T00:00" 
$dateTo = "D2015-05-05T00:00" 

$userName = $null 
$versionFrom = $null 
$versionFrom = [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::ParseSingleSpec($dateFrom, "") 
$versionTo = $null 
$versionTo = [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::ParseSingleSpec($dateTo, "") 


$path="c:\MyProject\SpecialFolder\*"
$path="$/TeamProject/Main/Portal-branch"
$locationToSearch = $path

$vCSChangeSets = $versionControlServer.QueryHistory($locationToSearch, $latest, 0, $recursionType, $userName, $versionFrom, $versionTo, [int32]::MaxValue, $true ,$false, $false, $true) 
$TargetChangeSetChangeItems = @()  


$TargetChangeSetChangeItems = foreach ($vCSChangeSet in $vCSChangeSets) 
{   
    foreach ($vCSChange in $vCSChangeSet.Changes) 
    { 
        $vCSItem =  $vCSChange.Item 

        # MORE CODE HERE, OMMITTED
    }
}

参考文献:
https://gallery.technet.microsoft.com/scriptcenter/Export-Foundation-Server-b664c8ce

这篇关于使用 Microsoft.TeamFoundation.Client 和 Powershell 从变更集中获取列表文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆