Something like this should work for you:
public void UpdateTFSValue(string tfsServerUrl, string fieldToUpdate,
string valueToUpdateTo, int workItemID)
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsUri));
_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItem workItem = _store.GetWorkItem(workItemId);
workItem.Open();
workItem.Fields[fieldToUpdate] = valueToUpdateTo;
workItem.Save();
}
An example of calling this might be:
UpdateTFSValue("http://tfs2010dev:8080/tfs", "Integration Build", "Build Name", 1234);
The variable fieldToUpdateshould be the name of the field, not refname (i.e. Integration Build, not Microsoft.VSTS.Build.IntegrationBuild)
You may be able to use PartialOpen () , but I'm not sure.
You will probably need to add Microsoft.TeamFoundation.Clientto your project. (And maybe Microsoft.TeamFoundation.Common)
source
share