【问题标题】:How to add a text file or xml content to a TFS WorkItem description in Powershell?如何将文本文件或 xml 内容添加到 Powershell 中的 TFS WorkItem 描述?
【发布时间】:2015-02-19 02:23:44
【问题描述】:

我想使用 powershell 在 TFS 工作项中添加一些描述。 我写了以下代码:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")

    # Get TFS server and query from WIQ file
        [xml]$WiqlXML = Get-Content $WiqPath
        [String]$TFSservername = $WiqlXML | % {$_.WorkItemQuery.TeamFoundationServer} 
        [String]$queryString = $WiqlXML | % {$_.WorkItemQuery.Wiql}
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($TFSservername)

    # Get workitem collection from TFS Project
    $ws = $teamProjectCollection.GetService([type][Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
    $wis = $ws.Query($queryString);

    [Net.WebClient] $request =  New-Object Net.WebClient
    $request.UseDefaultCredentials = $true
foreach($wi in $wis)
{
    $wi.Description += "`r`n========================================================"
    $wi.Description += "<xml>content</xml>"
}

但是,只在工作项中====================================== ==================已添加

【问题讨论】:

    标签: powershell tfs


    【解决方案1】:

    您的所有内容都已添加,但由于它是一个 HTML 框,因此不会呈现并消失。

    在将 xml 添加到描述字段之前,您需要对其进行 HTML 编码。

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 2017-12-17
      • 2021-12-10
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多