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:
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.
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 "$(BuildLogFile)" "$(ReleaseNotesXslFile)" -o "$(ReleaseNotesOutputFile)"" />
</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:
- MSBuild Community Tasks MSI from http://msbuildtasks.tigris.org/
- msxsl.exe copied to a directory on the PATH from Command Line Transformation Utility (msxsl.exe)
8 Comments
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?
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 ?
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]
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.”
…and I third this. This would be a really useful task – there must be some way round it?
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.
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/
Thanks Christian and Grant for providing an answer to this – invaluable in our project!
2 Trackbacks
[...] Link to Building a Release Notes Text File with Team Build « Grant Holliday [...]
[...] recently found out about a blog entry written by Grant Holliday, that describes how to extend an MS Build process within an automated [...]