5

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.

3 Answers 3

1

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.

3
  • Sadly this didn't work. I have to make the call to tfpt workitem all in one command. Nov 2, 2011 at 13:58
  • I saw that the Description fields is listed as an HTMLFieldControl. That's why I assumed <br /> tags would work. But I think they convert the < to &lt; and the > to &gt;. The <br /> text is displayed as is on the Description field. And the History control is listed as a WorkItemLogControl which apparently does accept HTML tags. Nov 2, 2011 at 18:46
  • TobyKraft's solution worked for me - can put in basic tables etc. as well
    – tollgen
    Oct 9, 2015 at 11:35
1

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.

0

Hate to mark this answered but I did add a workaround that worked for me. Although I added the "solution" to my problem in my OP. Here it is for clarity (thanks for the notion pantelif)

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.

1
  • Well, there is nothing wrong with marking as an answer something you 've managed to construct yourself. Just for the sake of clarity, please consider revising your answer so that it describes your technical solution. Accepting it, will be then perfectly ok.
    – pantelif
    Nov 4, 2011 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.