title: TFS 2010: How to produce a changelog (ie. list of work items) between two releases of the application using labels?
body: <p>I'm looking for a way to automatically produce a changelog (actually a list of workitems) between two releases of my application. I have two versions of my application, v1 and v2, each is identified by a label in TFS 2010 (LABEL1 and LABEL2) that I manually created before building the setups of my app.
  I have a branching system, which means I have a trunk were most of bugs are fixed, and a branch where patches are applied mostly using merges from the trunk (but there are also some fixes on the branch only that do not concern the trunk). The two versions of my application (v1 and v2) are versions from the branch.</p>
  
  <p>I would like TFS 2010 to be able to return the list of bugs that were fixed (ie. the list of work items with type = Bug that are closed and verified) between these two labels.</p>
  
  <p>I tried to achieve this using the web UI of TFS 2010, or using Visual Studio, but I didn't find any way.</p>
  
  <p>Then I tried to ask tf.exe for a history using the following command line:</p>
  
  <pre><code>tf history /server:http://server_url/collection_name "$/project_path" /version:LLABEL1~LLABEL2 /recursive /noprompt /format:brief
  </code></pre>
  
  <p>where LABEL1 is the label that has been associated with the source code of the v1 of the application, and LABEL2 the label that has been associated with the source code of the v2 of the application.
  It actually fails in two ways:
  - the command line only returns a list of changesets, not a list of associated closed work items
  - the list of changesets only contains the changesets that I applied on the branch itself, not the changesets that I also applied and the trunk and then merged to the branch. Setting or not the "/slotmode" parameter doesn't change anything.</p>
  
  <p>There I tried to write a piece of C# code to retrieve the list of workitems (not the list of changesets):</p>
  
  <pre><code>var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://server_url/collection_name"));
  
  VersionControlServer controlServer = tfs.GetService&lt;VersionControlServer&gt;();
  VersionControlServer vcs = tfs.GetService&lt;VersionControlServer&gt;();
  
  VersionSpec sFrom = VersionSpec.ParseSingleSpec("LLABEL1", null);
  VersionSpec sTo = VersionSpec.ParseSingleSpec("LLABEL2", null);
  
  var changesets = vcs.QueryHistory(
      "$/project_path",
      sTo,
      0,
      RecursionType.Full,
      null,
      sFrom,
      sTo,
      int.MaxValue,
      true,
      false); // Slotmode to false
  
  Dictionary&lt;int, WorkItem&gt; dico = new Dictionary&lt;int, WorkItem&gt;();
  foreach (Changeset set in changesets)
  {
      foreach (WorkItem zz in set.WorkItems)
      {
          if (!dico.ContainsKey(zz.Id))
          {
              dico.Add(zz.Id, zz);
          }
      }
  }
  
  foreach (KeyValuePair&lt;int, WorkItem&gt; pair in dico.OrderBy(z =&gt; z.Key))
  {
      Console.WriteLine(string.Format("ID: {0}, Title: {1}", pair.Key, pair.Value.Title));
  }
  </code></pre>
  
  <p>This actually works, I get the list of workitems between my two labels which is actually what I wanted. But only workitems associated to changesets that were committed on the branch itself are taken into account: the workitems of type "Bug" that were solved on the trunk then merged to the branch don't appear. Slotmode doesn't change anything.</p>
  
  <p>Then I finally tried to replace VersionSpecs that were defined by a label with VersionSpecs that are defined by changesets:</p>
  
  <pre><code>VersionSpec sFrom = VersionSpec.ParseSingleSpec("C5083", null);
  VersionSpec sTo = VersionSpec.ParseSingleSpec("C5276", null);
  </code></pre>
  
  <p>And my code finally works.</p>
  
  <p>So my question is: how could I get the same result with labels, which are the TFS objects I use to identify a version? If it's not possible, how should I identify a version in TFS 2010?
  Thx.</p>
  
  <p>Btw I found some questions on stackoverflow, but none of them gave me answers with labels. For instance:
  <a href="https://stackoverflow.com/questions/5327558/how-to-determine-the-work-items-associated-with-a-source-branch-in-tfs-2010">Question example</a></p>