Linking Setup project versions to TeamCity build numbers

Following my previous goal of linking the version numbers of our compiled files to the revision number of the SVN, I also wanted to link the installer project's version numbers so that every new build would automatically be treated as an upgrade to the previous build. I thought about using the Powershell script I had used in my previous post, but .vdproj files need new productcode and packagecode GUIDs every time you change the version number. I don't know how to easily generate GUIDs in Powershell, but I did stumble upon this handy tool, VS.Net Deployment ProjectUpdater that does just that.

I choose to link the setup project's version number to the primary binary file for which the installer exists to deploy. This binary, let's say it is Project1.exe, has its version set to match TeamCity's build count and the SVN revision number. In the post build event for Project1, I insert this command line script:

IF $(ConfigurationName) == Release (
   IF EXIST "$(VersionVDProj)" (
      "$(VersionVDProj)" -msi "$(ProjectDir)..\Project1Installer\Project1Installer.vdproj" version="$(TargetPath)"
   )
)

$(VersionVDProj), like in past posts, refers to an environment variable on the build machine I set to the full filename and path of the VersionVDProj executable. If you recall from past post about the devenvbuild runner I built, Project1Installer builds after Project1. The $(TargetPath) variable sets the vdproj version to match the major, minor and build version of Project1. If you followed my last post, Project1's version matches the TeamCity build and SVN revision number. So now the project installer version number matches the TeamCity build number every time it is built.