カスタム ビルド プロセス (MS ビルドを使用しない) があり、そのプロセス中に「偽の」ビルドをグローバル ビルド リストに追加しています。私がそうしているのは、(ビルドで見つかった) 特定の作業項目のビルドを選択できるようにするためです。ワークアイテムがどのビルドで修正されたかを表示するためのビルドを含むカスタム フィールドがあります。このフィールドをプログラムで更新する方法がわかりません。これを実行する小さなアプリをビルド プロセス中に呼び出して、最後のビルド以降のすべての作業項目を検索し、それらの作業項目のフィールドを更新するという考えです。何か案は?
7451 次
2 に答える
14
このようなものがうまくいくはずです:
public void UpdateTFSValue(string tfsServerUrl, string fieldToUpdate,
string valueToUpdateTo, int workItemID)
{
// Connect to the TFS Server
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsUri));
// Connect to the store of work items.
_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
// Grab the work item we want to update
WorkItem workItem = _store.GetWorkItem(workItemId);
// Open it up for editing. (Sometimes PartialOpen() works too and takes less time.)
workItem.Open();
// Update the field.
workItem.Fields[fieldToUpdate] = valueToUpdateTo;
// Save your changes. If there is a constraint on the field and your value does not
// meet it then this save will fail. (Throw an exception.) I leave that to you to
// deal with as you see fit.
workItem.Save();
}
これを呼び出す例は次のとおりです。
UpdateTFSValue("http://tfs2010dev:8080/tfs", "Integration Build", "Build Name", 1234);
変数fieldToUpdate
は、refname ではなく、フィールドの名前にする必要があります (つまり、 Microsoft.VSTS.Build.IntegrationBuildではなくIntegration Build ) 。
おそらくPartialOpen()を使用して回避できますが、よくわかりません。
おそらく、プロジェクトに追加する必要がありMicrosoft.TeamFoundation.Client
ます。(そして多分Microsoft.TeamFoundation.Common
)
于 2011-03-01T21:46:17.520 に答える