The version information, displayed when the mouse cursor hovers over the file in windows explorer, is set for a file built by visual studio in the VERSION resource. I would like to set the version in one place for all the files built by a solution, preferably when I change the version in the install properties. Is there a way to do this?
The motivation for this is that if the version is not updated for a file, then the installer will leave previous versions of files instead of replacing them with new files. This happens even when the 'RemovePreviousVersions' property is set. In order to save the tedious and error prone task of updating the version in every file built and installed, I remove the version resource from all files - which is not elegant.
The second answer in Stack Overflow topic How to programatically change a project's product version? features a solution for setting the version number from a common header file in C++. Just place the header file containing the hard-coded version numbers in a folder where each project can find it.
The above answer also describes a means of incrementing the version number. An alternate approach for C++ version incrementing is available from Microsoft's article How to increment version information after each build in Visual C++.
Alternately, you can use your source control repository revision number as part of the version number. The Stack Overflow article Creating a file with build number and branch name in SVN gives some insight into this for TortoiseSVN users. The following two articles explore this in more depth:
Integrating the Subversion Revision into the Version Automatically with .NET (C# or VB)
Integrating the Subversion Revision into the Version Automatically with Native C/C++
(the above two web pages feature links to similar procedures for TortoiseHg users)
In theory, you could have a single text file holding the new version number, then run a pre-build script that would: