Reputation: 109
I have been working on a small winform c# App that will enable me to create a work item in TFS without having to actually go on the TFS server. I have figured out how to add the title, attachments, description etc. However I cant seem to figure out how to insert a local image into the TFS work Item "Repro Steps" field. Here is my code so far.
Uri collectionUri = new Uri("Server Adress" + project);
TfsTeamProjectCollection server = new TfsTeamProjectCollection(collectionUri);
WorkItemStore store = (WorkItemStore)server.GetService(typeof(WorkItemStore));
WorkItem workItem = store.Projects[SubProject].WorkItemTypes["Bug"].NewWorkItem();
workItem.Title = "Title";
workItem.IterationPath = "Iteration";
workItem.AreaPath = "Area";
workItem.Fields["repro steps"].Value = "Text"; //Here is where I would like to add my image
workItem.Fields["Assigned To"].Value = "Assigned";
workItem.Attachments.Add(new Attachment(File, "comment"));
workItem.Save();
For further clarification here is what I am essentially trying to do:
Upvotes: 1
Views: 3030
Reputation: 19203
I believe that the Description
field is encoded as a variety of HTML and the image is first attached as a separate file. (Historically it was a text field so I cannot find anything saying otherwise)
Here is an example of attaching a file
Upvotes: 3