This has been an interesting nut to crack. There are several published ways to inject a version number into WiX as part of a TeamBuild process. This is the way that I have found has the best results.
The following target overrides the ResolveSolutionPathsForEndToEndIteration MSBuild target to inject a $(VersionNumber) value if a custom version number has been defined or calculated in the build script. The default implementation of ResolveSolutionPathsForEndToEndIteration is called if no version number has been defined or calculated.