Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a new WorkItem in TFS using TFPT command line tool with line breaks in Description field

How do I add a line break in the description field of a new WorkItem using the TFS 2010 Power Tools command line utility TFPT? I've tried this:

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"

and this:

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"

to no avail.

Any suggestions out there?

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

One workaround I have implemented is to create a new (actually extended) work item with properties that I was initially embedding in a long description. So, now I've broken them out into separate fields like:

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"

Then I created form fields (a new tab group) to display them. It's cleaner that way anyhow.

Still would be interesting to determine how to add line breaks with TFPT.

Thanks.

like image 273
beaudetious Avatar asked Nov 05 '22 11:11

beaudetious


2 Answers

Try this. In your case:

    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"

UPDATE: See this link. Search for TobyKraft's solution. He found that history is HTML formatted. First you have to add new workitem and then update workitem history with html formatted string using < br > tags.

like image 169
Ludwo Avatar answered Nov 29 '22 08:11

Ludwo


I wouldn't know how to help you out using tfpt.
You could construct a small console application that uses TFS-SDK instead and get the job done as follows:

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();
        }
    }
}

This gets the job done. Now if you make it depend on your string[] args, I expect that the method @Ludwo presented shall be usable.

The above bases on this.

like image 43
pantelif Avatar answered Nov 29 '22 08:11

pantelif