Building a Release Notes Text File with Team Build

The following post describes a Team Build target that generates a text file (e.g. ReleaseNotes.txt) from Team Build’s build log and places it with the build output.

This is useful if you want to distribute your product to somebody who won’t have access to your TFS server to view the build log history.

This is an example of the output that is generated:

Screenshot of Notepad showing contents of ReleaseNotes.txt 

How it works

Team Build compiles the solution and after it performs the GetChangesetsAndUpdateWorkItems task, we download the build log (as XML) using the Build.aspx web page that TFS provides.

The build log is an XML file that contains all the associated work items and changesets that have been included in the build.

We perform an XSL transform on this file to generate the text file output that we require.

Flow chart of creating the release notes file

Setup: TFSBuild.proj

To actually get Team Build to generate the release notes, we need override the AfterGetChangesetsAndUpdateWorkItems target and call our new target.

In source control, checkout the TFSBuild.proj file for your build definition and insert the following snippet at the end, just before the </Project> tag.

<Target Name="AfterGetChangesetsAndUpdateWorkItems">
  <CallTarget Targets="GenerateReleaseNotes" />
</Target>
 
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<!-- Download the build log from the Build.aspx web app and tranform to ReleaseNotes.txt-->
<Target Name="GenerateReleaseNotes">
  <PropertyGroup>
    <BuildDownloadBaseUri>$(TeamFoundationServerUrl)Build/Build.aspx?artifactMoniker=</BuildDownloadBaseUri>
    <BuildLogFile>buildlog.xml</BuildLogFile>
    <ReleaseNotesXslFile>$(MSBuildExtensionsPath)\releasenotes.xsl</ReleaseNotesXslFile>
    <ReleaseNotesOutputFile>$(OutDir)ReleaseNotes.txt</ReleaseNotesOutputFile>
  </PropertyGroup>
 
  <!-- Extract the artifact ID from the BuildUri for passing to Build.aspx -->
  <RegexReplace Input="$(BuildUri)" Expression="vstfs:///Build/Build/" Replacement="" Count="1">
   <Output ItemName="BuildLogUriId" TaskParameter="Output" />
  </RegexReplace>
 
  <WebDownload
    FileUri="$(BuildDownloadBaseUri)@(BuildLogUriId)"
    FileName="$(BuildLogFile)"
    UseDefaultCredentials="True" />
 
  <Exec Command="msxsl.exe &quot;$(BuildLogFile)&quot; &quot;$(ReleaseNotesXslFile)&quot; -o &quot;$(ReleaseNotesOutputFile)&quot;" />
</Target>

Configuration

Property Description Default
BuildDownloadBaseUri The URI to download the build log file from. $(TeamFoundationServerUrl)Build/Build.aspx?artifactMoniker=
BuildLogFile Path to output the downloaded build log to. buildlog.xml
ReleaseNotesXslFile Path to the XSL transform used to generate the release notes text file. $(MSBuildExtensionsPath)\releasenotes.xsl
ReleaseNotesOutputFile The output of the XSL transform $(OutDir)ReleaseNotes.txt

Build Server Setup

The following pre-requisite software is required for the build server:

More Information

8 Comments

  1. Roland
    Posted April 29, 2008 at 2:53 am | Permalink

    This doesn’t seem to work with TFS 2008 and the latest version of the MSBuild Community Tasks. Firstly, the UseDefaultCredentials property is no longer available for the WebDownload task.
    Secondly, I am constantly getting a 401 error durring my build when the WebDownload task tries to execute. Any ideas on how to get around this?

  2. Posted October 2, 2008 at 4:18 am | Permalink

    I am getting the same 401 errors trying to download the build file. Probably due to the usedefaultcredentials not being supported any longer.

    Any workarounds ?

  3. Ennovative
    Posted October 19, 2008 at 1:36 am | Permalink

    I am geting the same error as Randy…. The 401 error. Is there any way out ….. ?

    Please let us know …

    ==================================================

    Ennovative

    [url="www.widecircles.com"][/Link Building]

  4. Posted January 21, 2009 at 11:29 pm | Permalink

    I second this. Since I would really like to implement this feature, I wonder if anyone fixed that issue with UseDefaultCredentials yet.

    I also get
    “error : The remote server returned an error: (401) Unauthorized.”

  5. Peter Phillips
    Posted January 23, 2009 at 3:11 am | Permalink

    …and I third this. This would be a really useful task – there must be some way round it?

  6. Posted January 23, 2009 at 3:51 am | Permalink

    There is. I found the solution to this problem. The link presented here leads to an outdated version of the msi. Download it directly from tigris (nightly build). That one works.

    However, this article is still missing a sample xsl file. Wait another hour or two. I will post an article on my blog with a sample xsl that practically results in what the screenshot here shows.

  7. Posted February 9, 2009 at 3:45 pm | Permalink

    If you want the XSL, have a look at Christian’s blog post:

    http://www.trimagination.info/2009/01/23/automatically-generate-release-notes-textfile-from-team-foundation-build/

  8. Peter Phillips
    Posted February 10, 2009 at 8:15 am | Permalink

    Thanks Christian and Grant for providing an answer to this – invaluable in our project!


2 Trackbacks

  1. [...] Link to Building a Release Notes Text File with Team Build « Grant Holliday [...]

  2. [...] recently found out about a blog entry written by Grant Holliday, that describes how to extend an MS Build process within an automated [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*