Visual Studio 与 SubWCRev 自动构建版本控制问题
各位,
我正在使用 VS2010 并尝试使用 SubWCRev 将我的项目的构建版本与我的 Subversion 存储库同步。这一切都工作正常,但我无法完全理解一件事。我的模板文件由以下内容组成:
#define MAJOR_VERSION 2
#define MINOR_VERSION 2
#define MICRO_VERSION 0
#define BUILD_VERSION $WCMODS?$WCREV$+1:$WCREV$$
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
#define BUILD_VERSION_STRING QUOTE(MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION.BUILD_VERSION)
然后在我的应用程序 .RC 文件中,我有:
FILEVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_VERSION
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080004e4"
BEGIN
VALUE "FileVersion", BUILD_VERSION_STRING
VALUE "ProductVersion", BUILD_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x800, 1252
END
END
正如您可能知道的那样,如果有修改的代码,我会尝试将构建版本增加 1,以便 EXE 中的构建版本与当我发布版本并检查代码时,Subversion 修订版号。问题是 BUILD_VERSION 扩展为 x+1 或 x+0,然后在 BUILD_VERSION_STRING 中显示为“2.2.0.227+1”,这并不完全是我想要的。
有更多这方面经验的人知道如何实现我的目标吗? 提前致谢
Folks,
I'm using VS2010 and trying to sync the build version of my project with my Subversion repository using SubWCRev. This is all working correctly, but I can't quite get my head around one thing. My template file consists of this :
#define MAJOR_VERSION 2
#define MINOR_VERSION 2
#define MICRO_VERSION 0
#define BUILD_VERSION $WCMODS?$WCREV$+1:$WCREV$
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
#define BUILD_VERSION_STRING QUOTE(MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION.BUILD_VERSION)
Then in my application .RC file I have :
FILEVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_VERSION
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080004e4"
BEGIN
VALUE "FileVersion", BUILD_VERSION_STRING
VALUE "ProductVersion", BUILD_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x800, 1252
END
END
As you can probably work out, I'm trying to up the build version by 1 if there's modified code so that the build version in the EXE will match the Subversion revision number when I do a release and check the code in. The problem is that BUILD_VERSION gets expanded to x+1 or x+0 which then appears in the BUILD_VERSION_STRING as "2.2.0.227+1" which is not quite what I intended.
Does anyone with a little more experience with this know a way to achieve my aim?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在我的小组中,我们仅使用项目工作目录的 svn 修订号自动更新最不重要的值。为此,我们向每个项目添加了一个预构建步骤,该步骤创建然后调用执行以下操作的批处理脚本:
Im my group we only automate the update of the least significant value with the svn revision number for the projects working directory. To do this we have added a pre-build step to each project that creates and then calls a batch script that does the following:
如果您使用 subwcrev 从您的版本化模板生成未版本化标头,则
#include
您的未版本化标头版本化 .RC 文件,您可以从未修改的工作区进行构建以供发布。然后您就可以使用
这也消除了在构建发布 EXE 和签入代码之间发生任何更改的风险。
If you use subwcrev to generate an unversioned header from your versioned template, then
#include
the unversioned header in your versioned .RC file, you can build for release from an unmodified work area.Then you can just use
This also removes the risk of any changes creeping in between building your release EXE and checking in the code.
您能否执行以下操作:
编辑:正如评论中指出的那样,这也不起作用!
您的版本号的用途是什么?如果要返回用于生成二进制文件的源代码,那么您可能会在这里搬起石头砸自己的脚。如果有人在您创建版本号的同时将更多代码签入存储库,会发生什么情况?您最终将得到引用不同代码的二进制文件。
更好的方法可能是检查工作副本是否有任何修改或混合修订,并使用特定的修订号(例如
0xFFFFFFFF
或0
)来表示。如果您使用干净的树来构建二进制文件,则仅使用真实的修订号。Could you do something like:
Edit: This won't work either as pointed out in the comments!
What is the purpose of your version number? If it's to get back to the source code used to produce the binary then you might be shooting yourself in the foot a bit here. What happens if someone checks some more code into the repository at the same time as you're creating your version number? You're going to end up with your binary referencing different code.
What might be better would be to check to see if the working copy has any modifications or mixed revisions and use a specific revision number (e.g.
0xFFFFFFFF
or0
) to represent this. And only use the true revision number if you used a clean tree to build the binary.