本文翻译自:How to have an auto incrementing version number (Visual Studio)? [duplicate]
This question already has an answer here: 这个问题在这里已有答案:
I want to store a set of integers that get auto incremented at build time: 我想存储一组在构建时自动递增的整数:
int MajorVersion = 0;
int MinorVersion = 1;
int Revision = 92;
When I compile, it would auto-increment Revision
. 当我编译时,它会自动增加Revision
。 When I build the setup project, it would increment MinorVersion
(I'm OK with doing this manually). 当我构建安装项目时,它会增加MinorVersion
(我可以手动执行此操作)。 MajorVersion
would only be incremented manually. MajorVersion
只会手动增加。
Then I could display a version number in menu Help/About to the user as: 然后我可以在菜单Help / About中向用户显示版本号:
Version: 0.1.92
How can this be achieved? 怎么能实现这一目标?
This question asks not only how to have an auto-incrementing version number, but also how to use that in code which is a more complete answer than others. 这个问题不仅要求如何使用自动递增版本号,还要求如何在代码中使用它,这是一个比其他更完整的答案。
#1楼
参考:https://stackoom.com/question/3T57/如何拥有自动递增版本号-Visual-Studio-重复
#2楼
This is my implementation of the T4 suggestion... This will increment the build number every time you build the project regardless of the selected configuration (ie Debug|Release), and it will increment the revisio