【发布时间】:2011-11-29 19:53:51
【问题描述】:
虽然我知道有一个命令行工具可以永久删除 TFS 工作项。 (例如How to delete Work Item from Team Foundation Server)
是否有人能够使用 TFS 2010 API DLL 以编程方式实现相同的操作?
【问题讨论】:
虽然我知道有一个命令行工具可以永久删除 TFS 工作项。 (例如How to delete Work Item from Team Foundation Server)
是否有人能够使用 TFS 2010 API DLL 以编程方式实现相同的操作?
【问题讨论】:
Shai Raiten 曾在博客上写过这个here,他在其中使用了DestroyWorkItems(ids)。
建议您在实施过程中格外小心,因为这会严重扰乱您的安装。有人可能会争辩说,构建这样一个工具偏离了最佳实践。
【讨论】:
你也可以use PowerShell to bulk delete work items:
将以下脚本复制并粘贴到 PowerShell 文件中(使用 .ps1 扩展名),更新下面列表 #4 中提到的变量值 并从安装了 witadmin 工具的机器上运行命令 (一般在visual studio安装后可用)。打开 PowerShell 命令窗口并执行脚本。 注意:在脚本下运行的帐户应具有团队基金会管理员或集合管理员访问权限。
########TFS Work Items Bulk Destroy Automation Script########## #Notes: #1) This script requires to setup file/folder path, validate the file/folders path before running the script #2) start the powershell window as Administrator and run the script #3) This script requires share and admin access on the destination server, make sure your account or the account under which script is # executing is member of admin group on the destination server #4) Update following: # 4.1: $CollectionURL # 4.2: $WitAdmin tool location # For VS 2015, Default location is C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE # For VS 2013, Default location is C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE # 4.3: $WI_List # 4.4: $logfile #################### $CollectionURL = "http://tfs:8080/tfs/CollectionName" $WitAdminLocation = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" $WI_List = Get-Content "C:\WI_List.txt" $logfile="C:\log.txt" $ExecutionStartTime = Get-Date $WICount = 0 "## Starting WI Destroy @ $ExecutionStartTime ##"| Out-File $logfile -Append "Collection URL: $CollectionURL" | Out-File $logfile -Append foreach ($WIID in $WI_List) { CD $WitAdminLocation .\witadmin destroywi /collection:$CollectionURL /id:$WIID /noprompt "WI ID: $WIID Destroyed" | Out-File $logfile -Append $WICount = $WICount + 1 Write-Host "$WICount Work Items Deleted" } $ExecutionEndTime = Get-Date "## WI Destroy Command Completed @ $ExecutionEndTime ##"| Out-File $logfile -Append $TotalExecutionTime = $ExecutionEndTime - $ExecutionStartTime "Total Work Items Deleted: $WICount" | Out-File $logfile -Append " Total Execution Time: $TotalExecutionTime" | Out-File $logfile -Append ##End of script##
【讨论】: