简体   繁体   English

使用Powershell从TFS获取最新版本的文件夹

[英]Get Latest Version of Folder from TFS, using Powershell

I am trying to " Get Latest Version " of a particular folder from TFS, using Powershell. 我正在尝试使用Powershell从TFS“ 获取最新版本 ”的特定文件夹。

I have installed the TFS Snappin, and have been using TFS Power Tools cmdlets in PowerShell (such as Get-TfsChildItem and Select-TfsItem etc) [ How do I set up TFS PowerShell Snapin ], and have gone through their documentation (which I didn't find explanatory enough!). 我已经安装了TFS Snappin,并且一直在PowerShell中使用TFS Power Tools cmdlet(例如Get-TfsChildItem和Select-TfsItem等)[ 我如何设置TFS PowerShell Snapin ],并且已经完成了他们的文档(我没有找不到足够的解释!)。

Confused, on the exact cmdlet to use, when I am trying to get the latest version of an entire Folder structure from TFS, that is mapped to my local drive ( and not just a changeset or ChildItem ). 困惑,在我要使用的确切cmdlet上,当我试图从TFS获取整个文件夹结构的最新版本时,映射到我的本地驱动器( 而不仅仅是变更集或ChildItem )。

Example : Tfs Path - $/APD-RepairSolutions/Main/Database 示例:Tfs路径 - $ / APD-RepairSolutions / Main / Database

Mapped path - D:\\TFS\\APD-RepairSolutions/Main/Database. 映射路径 - D:\\ TFS \\ APD-RepairSolutions / Main / Database。

I want a code, that would iteratively get the latest version of the entire folder Database ,( that has number of tables,stored procedures etc.) 我想要一个代码,它将迭代地获取整个文件夹数据库的最新版本(具有多个表,存储过程等)

I am using .. 我在用 ..

PS D:\Tfs\APD-RepairSolutions\Main\Database> $server=Get-TfsServer -Name http://tfs:8080/tfs

PS D:\Tfs\APD-RepairSolutions\Main\Database> Get-TfsChangeset -Recurse -Server $Server

Not helping my case - as it is only returning the latest changeset in the current directory. 没有帮助我的情况 - 因为它只返回当前目录中的最新变更集。

To get latest ( tf get ) use Update-TfsWorkspace . 要获得最新( tf get ),请使用Update-TfsWorkspace

Get-TfsChangeset is the equivalent of tf changeset . Get-TfsChangeset相当于tf changeset

Gotcha! 疑难杂症! with Update-TFSWorskpace. 使用Update-TFSWorskpace。 Has some helpful parameters as well. 还有一些有用的参数。 -Items is used to specify the exact items you want to update. -Items用于指定要更新的确切项目。

PS D:\Tfs\APD-RepairSolutions\Main>Update-TFSWorkspace -All -Overwrite -Force -Recurse -Items .\Database

The Workspace is replaced with updated versions of items. 工作区将替换为更新版本的项目。 Thanks @Kmoraz! 谢谢@Kmoraz!

If you would like to use the TFS API instead, you can use the Workspace.Get Method : 如果您想使用TFS API,可以使用Workspace.Get方法

# Load the TFS assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
$ws = $vcServer.QueryWorkspaces("<WORKSPACENAME>", $null, $null);

# Specify properties of intended workspace get
$recursionType = [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full
$latestVersion = [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest
$getOptions = [Microsoft.TeamFoundation.VersionControl.Client.GetOptions]::GetAll

# Get what I want!
$ws.Get("$/Remote/Folder", $latestVersion, $recursionType, $getOptions)

Would be a good idea to replace the nulls with your domain login and computer name when Querying Workspaces . 查询工作区时,用域登录名和计算机名替换空值是个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM