1

虽然我知道有一个命令行工具可以永久删除 TFS 工作项。(例如如何从 Team Foundation Server 中删除工作项

有没有人能够使用 TFS 2010 API DLL 以编程方式实现相同的操作?

4

2 回答 2

1

Shai Raiten 在这里写了关于这个的博客,他在那里使用DestroyWorkItems(ids)

建议您在实施时格外小心,因为这会严重扰乱您的安装。有人可能会争辩说,构建这样一个工具偏离了最佳实践。

于 2011-10-03T10:45:22.750 回答
-1

您还可以使用 PowerShell 批量删除工作项

将以下脚本复制并粘贴到 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##
于 2015-11-22T01:30:15.300 回答