简体   繁体   English

使用Powershell根据TFS下载文件从TFS下载文件

[英]Download Files from TFS based on theirs labes using powershell

How can i find and download files from tfs based on their labels using powershell. 我如何使用Powershell根据标签从tfs查找和下载文件。 i found a code that downloads the latest version, but i want a specific labeled version. 我找到了下载最新版本的代码,但是我想要一个特定的标记版本。

You could call tf command in the powershell script to do this, the steps required to pull a label from TFS e as follows: 您可以在powershell脚本中调用tf命令来执行此操作,从TFS e提取标签所需的步骤如下:

  1. Specify the following as input parameters: Disk location where label is pulled (source code directory) TFS work space and folder from which code is pulled Label name associated with TS work space and folder 指定以下参数作为输入参数:提取标签的磁盘位置(源代码目录)TFS工作空间和从中提取代码的文件夹与TS工作空间和文件夹关联的标签名称
  2. Delete existing code from the source code directory 从源代码目录中删除现有代码
  3. Create the source code directory 创建源代码目录

  4. Change the current-working directory to the source code directory The reason for this is outlined in: "Build Automation: Getting multiple labels from TFS using TF GET (without deleting the files associated with the previous TF GET)" (optional) 将当前工作目录更改为源代码目录。其原因如下:“构建自动化:使用TF GET从TFS获取多个标签(不删除与先前TF GET关联的文件)”(可选)

  5. Delete the TFS work space if it exists aka tf workspace /delete 删除TFS工作空间(如果存在),即tf工作区/ delete

  6. Create the TFS work space aka tf workspace /new 创建TFS工作空间aka tf工作区/ new

  7. Map the source code folder to the collection folder and associate this mapping with the work space aka tf workfold /map 将源代码文件夹映射到collection文件夹,并将此映射与工作空间aka tf workfold / map关联
  8. Get the label from TFS aka tf get /version:L<label name> /noprompt 从TFS aka tf get /version:L<label name> /noprompt标签, tf get /version:L<label name> /noprompt

Detail code please refer this blog: How to Correctly pull labels from TFS using PowerShell 详细代码请参考此博客: 如何使用PowerShell从TFS正确提取标签

Another way is using TFS API, instead of directly get latest, you could use a VersionSpec to specify which version you want. 另一种方法是使用TFS API,而不是直接获取最新版本,而可以使用VersionSpec来指定所需的版本。 Such as a DateVersionSpec, a ChangeVersionSet or a LabelVersionSet. 例如DateVersionSpec,ChangeVersionSet或LabelVersionSet。 Detail code please refer How to use the TFS API to retrieve a historical version of your project , you could - involve TFS API in PowerShell. 详细代码,请参阅如何使用TFS API检索项目的历史版本 ,您可以-在PowerShell中使用TFS API

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

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