Team
System

Visual Studio Team System: tips, tricks, and
techniques

Search

Go

Most Recent Items

Listing
all Labels attached to a file or folder

Adding
the Build Number to your Team Build binaries

Working
"Offline" under Team System

Subscribing
to Team Foundation Server Events

Setting
up Continuous Integration with Team Build

Links

Let us help you
implement Team System!

FAQ: Team Foundation
Server

FAQ:
Team System Developer Center

Official
Team System Forums

Archives

July
2006 (5)

June
2006 (3)

May
2006 (7)

April
2006 (6)

March
2006 (11)

February
2006 (18)

January
2006 (19)

My Links

RSS 2.0

Atom 0.3

Navigation

Blogs

Adding the Build Number to your Team Build binaries

If you're using Team Build, you may want to "tag" the binaries produced
with the name of the build.

In order to do this, we'll customize the Team Build script (TFSBuild.proj)
for the project, hooking in to the default Team Build BeforeCompile
event. Check TFSBuild.proj out via the Source Control Explorer, and open it
for editing. Add these lines to the bottom of the build script:

<!-- customized extensibility event BeforeCompile -->
<Target Name="AfterGet" DependsOnTargets="VersionAssemblies">
<Message Text="AfterGet is firing!"/>
</Target>

<!-- add build number to AssemblyDescription field -->
<Target Name="VersionAssemblies" DependsOnTargets ="GetAssemblyInfos">
<Attrib Files="@(AssemblyInfos)" ReadOnly="false"/>
<FileUpdate Files="@(AssemblyInfos)" Regex="AssemblyDescription\(&quot;[^&quot;]*&quot;\)"
ReplacementText ="AssemblyDescription(&quot;$(BuildNumber)&quot;)" />
</Target>

<!-- get a list of all AssemblyInfo files -->
<Target Name="GetAssemblyInfos">
<CreateItem Include ="..\**\AssemblyInfo.cs">
<Output ItemName ="AssemblyInfos" TaskParameter="Include"/>
</CreateItem>
<Message Text="These AssemblyInfo.cs files were found:"/>
<Message Text ="@(AssemblyInfos)"/>
</Target>

You'll also need to download the MSBuild Community tasks, and install
those on your build server. Add a reference to the MSBuild Community tasks near
the top of your TFSBuild.proj file, like so:

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />

Check in the TFSBuild.proj file, then perform a build.. and watch the
magic happen!

What we're really doing is popping the $(BuildNumber) variable into the
AssemblyInfo.cs file. Specifically, we're putting it in the
AssemblyDescription field:

[assembly: AssemblyTitle("WindowsFormsClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Vertigo Software")]
[assembly: AssemblyProduct("WindowsFormsClient")]
[assembly: AssemblyCopyright("Copyright © Vertigo Software 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

After executing the build, note that the binary files will have the build
number in the Comments area in the standard Windows file properties dialog:

posted on Thursday, July 06, 2006 4:07 PM by jatwood

Post a
Comment ::

Comments

#
Adding build numbers to your binaries using Team Build.

Thursday, July 06,
2006 11:58 PM by notgartner.com: Mitch Denny's Blog

#
VSTS Links - 07/07/2006

Rob Caron on FTPOnline - Special Report: Visual Studio
Team System, TheServerSide.NET - Team System and...

Friday, July 07, 2006
6:59 AM by Team System News

#
Volete sapere con quale build sono stati creati i vostri eseguibili

Saturday, July 08,
2006 5:06 AM by http://blogs.vertigosoftware.com/utility/Redirect.aspx?U=http%3a%2f%2fblogs.ugidotnet.org%2flbarbieri%2farchive%2f2006%2f07%2f08%2f44281.aspx

Copyright © Vertigo Software,
Inc.