Automatically increment file version numbers in Visual Studio
The task of automatically incrementing file build and version numbers in Visual Studio seems complicated. However, with the release of Visual Studio 2008, this process has been simplified.
To implement automatic version increment, find the AssemblyInfo.cs file in your project. In this file you will find two lines of code that define the assembly version and the assembly file version:
<code>[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]</code>
While it may be tempting to use wildcards to auto-increment these numbers (e.g. [assembly: AssemblyVersion("1.0.*")]), this only updates the product version, leaving the file version unchanged.
To correctly set the file version to be the same as the product version, remove the second line (which defines AssemblyFileVersion) and keep only the line that defines AssemblyVersion:
<code>[assembly: AssemblyVersion("1.0.*")]</code>
With this modification, Visual Studio will automatically increment the product version and file version, ensuring they stay in sync. For example, your version number might now read "1.0.3266.92689," where the last four digits reflect the build number.
The above is the detailed content of How Can I Automate File Version Number Increments in Visual Studio?. For more information, please follow other related articles on the PHP Chinese website!