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)
More Information
Filed under: TFSBuild.com, Team Foundation Server |
Search
You are currently browsing the Grant Holliday weblog archives.
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]