【问题标题】:Creating a new WorkItem in TFS using TFPT command line tool with line breaks in Description field使用 TFTP 命令行工具在 TFS 中创建新的工作项,在描述字段中带有换行符
【发布时间】:2011-11-01 18:51:08
【问题描述】:

如何使用 TFS 2010 Power Tools 命令行实用程序 TFPT 在新工作项的描述字段中添加换行符?我试过这个:

Z:\>tfpt workitem /new "Project Ipsum\Issue" /collection:http://myserver:8080/tfs/test /fields:"Title=Testing Command Line 3;Description=Description of issue goes here<br /><br />I'd like to have line breaks too"

还有这个:

Z:\>tfpt workitem /new "Project Ipsum\Issue" /collection:http://myserver:8080/tfs/test /fields:"Title=Testing Command Line 3;Description=Description of issue goes here\r\nI'd like to have line breaks too"

无济于事。

有什么建议吗?

=============================

我实施的一种解决方法是创建一个新的(实际上是扩展的)工作项,其中包含我最初嵌入在长描述中的属性。所以,现在我将它们分成单独的字段,例如:

Z:\>tfpt workitem /new "Project Ipsum\Issue" /collection:http://myserver:8080/tfs/test /fields:"Title=Testing Command Line 3;Description=Description of issue goes here;Field1=more info;Field2=even more data"

然后我创建了表单域(一个新的选项卡组)来显示它们。反正这样更干净。

确定如何使用 TFPT 添加换行符仍然很有趣。

谢谢。

【问题讨论】:

    标签: tfs-power-tools


    【解决方案1】:

    Try this。在你的情况下:

        Z:\>set NLM=^
        Z:\>set NL=^^^%NLM%%NLM%^%NLM%%NLM%
        Z:\>tfpt workitem /new "Project Ipsum\Issue" /collection:http://myserver:8080/tfs/test /fields:"Title=Testing Command Line 3;Description=Description of issue goes here%NL%I'd like to have line breaks too"
    

    更新:见this link。搜索 TobyKraft 的解决方案。他发现历史是 HTML 格式的。首先,您必须添加新的工作项,然后使用
    标签使用 html 格式的字符串更新工作项历史记录。

    【讨论】:

    • 遗憾的是这不起作用。我必须在一个命令中调用 tfpt workitem。
    • 我看到描述字段被列为 HTMLFieldControl。这就是为什么我认为
      标签会起作用的原因。但我认为他们将 到 >。
      文本按原样显示在描述字段中。并且 History 控件被列为 WorkItemLogControl,它显然接受 HTML 标记。
    • TobyKraft 的解决方案对我有用 - 也可以放入基本表格等
    【解决方案2】:

    我不知道如何帮助您使用 tfpt。
    您可以构建一个使用 TFS-SDK 的小型控制台应用程序,并按如下方式完成工作:

    using System;
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.WorkItemTracking.Client;
    
    namespace GenerateWorkItem
    {
        class Program
        {
            static void Main(string[] args)
            {
                TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://myserver:8080"));
                WorkItemStore workItemStore = (WorkItemStore)tpc.GetService(typeof(WorkItemStore));
    
                Project teamProject = workItemStore.Projects["Ipsum"];
                WorkItemType workItemType = teamProject.WorkItemTypes["Issue"];
    
                WorkItem Issue = new WorkItem(workItemType)
                {
                    Title = "Testing Command Line 3",
                    Description = "Description of issue goes here \n I'd like to have line breaks too"
                }
                ;
                Issue.Save();
            }
        }
    }
    

    这样就完成了工作。 现在,如果你让它依赖于你的string[] args,我希望@Ludwo 提出的方法应该是可用的。

    以上内容基于this。

    【讨论】:

      【解决方案3】:

      讨厌将此标记为已回答,但我确实添加了一个对我有用的解决方法。尽管我在我的 OP 中为我的问题添加了“解决方案”。这是为了清楚起见(感谢pantelif的概念)

      我实施的一种解决方法是创建一个新的(实际上是扩展的)工作项,其中包含我最初嵌入在长描述中的属性。所以,现在我将它们分成单独的字段,例如:

      Z:\>tfpt workitem /new "Project Ipsum\Issue" /collection:http://myserver:8080/tfs/test /fields:"Title=Testing Command Line 3;Description=Description of issue goes here;Field1=more info;Field2=even more data"
      

      然后我创建了表单域(一个新的选项卡组)来显示它们。反正这样更干净。

      确定如何使用 TFPT 添加换行符仍然很有趣。

      【讨论】:

      • 嗯,将您自己构建的东西标记为答案并没有错。只是为了清楚起见,请考虑修改您的答案,以便它描述您的技术解决方案。接受它,就完全没问题了。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-27
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      相关资源
      最近更新 更多