Visual Studio 与 SubWCRev 自动构建版本控制问题

发布于 2024-10-27 12:21:30 字数 1260 浏览 2 评论 0原文

各位,

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

匿名的好友 2024-11-03 12:21:30
#define BUILD_VERSION       $WCMODS?$WCREV+1$:$WCREV$
#define BUILD_VERSION       $WCMODS?$WCREV+1$:$WCREV$
梦萦几度 2024-11-03 12:21:30

在我的小组中,我们仅使用项目工作目录的 svn 修订号自动更新最不重要的值。为此,我们向每个项目添加了一个预构建步骤,该步骤创建然后调用执行以下操作的批处理脚本:

  1. 将 $(ProjectDir)Properties\AssemblyInfo.cs 复制到 $(ProjectDir)Properties\AssemblyInfo.cs.template。
  2. 在 $(ProjectDir)Properties\AssemblyInfo.cs.template 中查找 AssemblyVersion("XYZddd") 并替换为 AssemblyVersion("XYZ$WCREV$")。
  3. 在 $(ProjectDir)Properties\AssemblyInfo.cs.template 中查找 AssemblyFileVersion("XYZddd") 并替换为 AssemblyFileVersion("XYZ$WCREV$")。
  4. 运行 'SubWCRev $(ProjectDir) $(ProjectDir)Properties\AssemblyInfo.cs.template $(ProjectDir)Properties\AssemblyInfo.cs'

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:

  1. Copy $(ProjectDir)Properties\AssemblyInfo.cs to $(ProjectDir)Properties\AssemblyInfo.cs.template.
  2. Find AssemblyVersion("X.Y.Z.ddd") in $(ProjectDir)Properties\AssemblyInfo.cs.template and replace with AssemblyVersion("X.Y.Z.$WCREV$").
  3. Find AssemblyFileVersion("X.Y.Z.ddd") in $(ProjectDir)Properties\AssemblyInfo.cs.template and replace with AssemblyFileVersion("X.Y.Z.$WCREV$").
  4. Run 'SubWCRev $(ProjectDir) $(ProjectDir)Properties\AssemblyInfo.cs.template $(ProjectDir)Properties\AssemblyInfo.cs'
伴我老 2024-11-03 12:21:30

如果您使用 subwcrev 从您的版本化模板生成未版本化标头,则#include您的未版本化标头版本化 .RC 文件,您可以从未修改的工作区进行构建以供发布。

然后您就可以使用

#define BUILD_VERSION       $WCREV$

这也消除了在构建发布 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

#define BUILD_VERSION       $WCREV$

This also removes the risk of any changes creeping in between building your release EXE and checking in the code.

眸中客 2024-11-03 12:21:30

您能否执行以下操作:

#define MOD_VERSION $WCMODS?1:0$
#define REVISION $WCREV$
#define BUILD_VERSION ( REVISION + MOD_VERSION )

编辑:正如评论中指出的那样,这也不起作用!

您的版本号的用途是什么?如果要返回用于生成二进制文件的源代码,那么您可能会在这里搬起石头砸自己的脚。如果有人在您创建版本号的同时将更多代码签入存储库,会发生什么情况?您最终将得到引用不同代码的二进制文件。

更好的方法可能是检查工作副本是否有任何修改或混合修订,并使用特定的修订号(例如 0xFFFFFFFF0)来表示。如果您使用干净的树来构建二进制文件,则仅使用真实的修订号。

#define MAJOR_VERSION       2
#define MINOR_VERSION       2
#define MICRO_VERSION       0
#if $WCMODS?1:0$
#define BUILD_VERSION       0
#else
#define BUILD_VERSION       $WCREV$
#endif

Could you do something like:

#define MOD_VERSION $WCMODS?1:0$
#define REVISION $WCREV$
#define BUILD_VERSION ( REVISION + MOD_VERSION )

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 or 0) to represent this. And only use the true revision number if you used a clean tree to build the binary.

#define MAJOR_VERSION       2
#define MINOR_VERSION       2
#define MICRO_VERSION       0
#if $WCMODS?1:0$
#define BUILD_VERSION       0
#else
#define BUILD_VERSION       $WCREV$
#endif
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文