views:

71

answers:

1

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.

A: 

To centralize versioning for a solution:

  1. Take the version info out of AssemblyInfo.cs;
  2. Create a new file (GlobalAssemblyInfo.cs) and put your version info in it (using * to get VS to create a new version number for each build);
  3. Reference GlobalAssemblyInfo.cs as a link: Add | Existing Item then drop down the Add button in file selection to choose Add as Link instead;
  4. Repeat for each project in the solution;

I use a block like this for the version:

#if DEBUG

[assembly: AssemblyVersion("1.8.0.0")]

#else

[assembly: AssemblyVersion("1.8.*")]

#endif

This keeps VS from rebuilding every assembly during development, but gives every assembly a new version number when I build a release.

Ragoczy
What is 'AssemblyInfo.cs'. I do not have such a file, or anything similar.
ravenspoint
The versioninfo is stored in a file called (projectname).rc
ravenspoint
It looks like 'AssemblyInfo.cs' is used for .NET managed code. My projects are all straight forward C++. The * to get VS to create a new version number for each build looks very neat, but does not seem to work for my project.
ravenspoint
Perhaps a GlobalVersion.rc included in all the individual project rc files?
ravenspoint
Unfortunately, I'm not sure how it could be done in c++. :(
Ragoczy