使用TFTP命令行工具在TFS中创建新的工作项,并在“描述”字段中使用换行符

时间:2011-11-01 18:51:09

标签: tfs2010 tfs-power-tools

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

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添加换行符仍然很有趣。

感谢。

3 个答案:

答案 0 :(得分: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格式的。首先,您必须添加新的工作项,然后使用&lt;&lt; html格式化字符串更新工作项历史记录br&gt;标签。

答案 1 :(得分:1)

我不知道如何帮助你使用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

答案 2 :(得分:0)

讨厌回答,但我添加了一个对我有用的解决方法。虽然我在我的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添加换行符仍然很有趣。