stephl001

Greeting,

I have created a custom WorkItem; let's call it a cwi. I am able to create new cwi from the command line using tfpt like this:

tfpt workitem /new project\cwi /fields:"Title=mytitle"

My next step is to be able to specify a link to a changeset when I create the custom work item. I have not been able to find any hint that this is possible and I need your help on this to see what can be done.

Thanks,

Marc



Re: Team Foundation Server 每 Power Tools & Add-ons How can I create a link to a changeset with Power Toys "tfpt workitem /new ..."

Swamy Subramanian

Hi,

I don't think you can specify a link to changeset using tfpt workitem. Instead you can use TFS WorkItem and VersionControl APIs to accomplish this. Following is sample that shows how to add a changeset link to a workitem. You can find TFS SDK at http://msdn2.microsoft.com/en-us/library/bb130146(VS.80).aspx

Add reference to following TFS assemblies

Microsoft.TeamFoundation.Client.dll

Microsoft.TeamFoundation.Common.dll

Microsoft.TeamFoundation.VersionControl.Client.dll

Microsoft.TeamFoundation.WorkItemTracking.Client.dll

Add following using statements

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

using Microsoft.TeamFoundation;

using Microsoft.TeamFoundation.VersionControl.Client;

using Microsoft.TeamFoundation.VersionControl.Common;

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("MyTFSServer");

WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

Changeset myChangeset = versionControl.GetChangeset(3);

WorkItem wi1 = store.GetWorkItem(8);

wi1.Open();

wi1.Links.Add(new ExternalLink(store.RegisteredLinkTypes[ArtifactLinkIds.Changeset], myChangeset.ArtifactUri.AbsoluteUri));

wi1.Save();

Hope this helps






Re: Team Foundation Server 每 Power Tools & Add-ons How can I create a link to a changeset with Power Toys "tfpt workitem /new ..."

stephl001

Thanks, it did help.