I am trying to automate the creation and managing of TFS items. I have the following code to create a TFS item:
try
{
Uri collectionUri = new Uri("http://TFSServer:8080");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["ProjectName"];
WorkItemType workItemType = teamProject.WorkItemTypes["ProjectNameTask"];
WorkItem userStory = new WorkItem(workItemType)
{
Title = "Recently ordered menu 2",
Description = "As a return customer, I want to see items that I've recently ordered",
State = "Proposed"
};
var invalidFields = userStory.Validate();
userStory.Save();
}
catch (Exception exception)
{
Console.WriteLine("Exception occurred: " + exception.ToString());
throw;
}
The call userStory.Validate() is returning one item in invalidFields with details:
Name: Issue Type
ReferenceName: IssueType
But, WorkItem does not have an element of type IssueType. So the following code is giving a compilation error:
WorkItem userStory = new WorkItem(workItemType)
{
Title = "Recently ordered menu 2",
Description = "As a return customer, I want to see items that I've recently ordered",
State = "Active",
IssueType = "Some Issue"
};
with error saying "Cannot resolve symbol 'IssueType'". This might be because I dont have access to the right dlls for the specific TeamProject. I think resolving one of the following two ideas might help:
How can I get the correct dlls for a specific TeamProject's WorkItem?
or
Is it possible to add a field to an object type? I tried to create a new class by extending WorkItem, but it is a sealed class in the namespace Microsoft.TeamFoundation.WorkItemTracking.Client.
Wondering how to resolve the issue.
invalidFields[0].Status
? – MichaelWork Item Type
instead ofProjectNameTask
– Reza Aghaei