This project is read-only.

How to Modify the Build Number

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

In order to customize the build number in your compiled assemblies, you need to generate the replacement build number and then write it to the assemblyinfo source file.

In order to customize the build number property displayed in the Team Build interface, you need to override the $(BuildNumber) property in the BuildNumberOverride target.

To customize the build number in both the assembly and in the Team Build interface
  1. Override the $(BuildNumber) in the BuildNumberOverride target.
  2. Override the BeforeCompile target to write the AssemblyInfo.cs or .vb file.

Example
 <Target Name="BuildNumberOverrideTarget">
    <Message Importance="High" Text="$(BuildNumber)" />
 
    <ConvertTFSBuildNumberToSolutionBuildNumber
      MajorAndMinorVersion="1.0"
      TFSBuildNumber="$(BuildNumber)"
      TFSLastBuildNumber="$(LastBuildNumber)">
      <Output TaskParameter="SolutionBuildNumber" PropertyName="SolutionBuildNumber" />
      <Output TaskParameter="TFSBuildNumber" PropertyName="BuildNumber" />
    </ConvertTFSBuildNumberToSolutionBuildNumber>
    <Message Importance="High" Text="$(SolutionBuildNumber)" />
    <Message Importance="High" Text="$(BuildNumber)" />
  </Target>
 
  <Target Name="BeforeCompile">
    <Message Importance="High" Text="$(SolutionBuildNumber)" />
    <CreateItem Include="$(SolutionRoot)\**\AssemblyInfo.cs">
      <Output TaskParameter="Include" ItemName="AssemblyInfoFiles"/>
    </CreateItem>
    <CreateItem Include="$(SolutionRoot)\**\AssemblyInfo.vb">
      <Output TaskParameter="Include" ItemName="AssemblyInfoFiles"/>
    </CreateItem>
    <RewriteFileVersions 
      AssemblyInfoFiles="@(AssemblyInfoFiles)"
      AssemblyVersionNumber="$(SolutionBuildNumber)" 
      AssemblyFileVersionNumber="$(SolutionBuildNumber)" 
      AssemblyInformationalVersionNumber="$(SolutionBuildNumber)" />
  </Target>

Additional Resources

Last edited Jul 26, 2007 at 6:55 AM by prashantbansode, version 1

Comments

learnerplates Mar 9, 2009 at 1:26 PM 
where can I find the "ConvertTFSBuildNumberToSolutionBuildNumber" task????
I've installed the AssemblyInfo Task, gotdotnet no longer exists it can now be found here http://code.msdn.microsoft.com/AssemblyInfoTaskvers/Release/ProjectReleases.aspx?ReleaseId=232.
I've isntalled it but it still cannot find "ConvertTFSBuildNumberToSolutionBuildNumber" !!!!!!!!!!!!!!!!!!

FreeToDev Jul 30, 2008 at 7:26 PM 
A lightweight versioning alternative: http://freetodev.spaces.live.com/blog/cns!EC3C8F2028D842D5!547.entry

FreeToDev
www.codeplex.com/freetodevtasks