问题描述
我想让我的.exe可以访问我的svn版本的资源字符串。我可以手动键入,但我更喜欢一个自动化的方式来嵌入在编译时。在Visual Studio 2008中有这样的功能吗?
我想要一个类似的可用性,发现$ Rev $不足,如果文件的修订版本被更改(这意味着它必须被编辑和提交很长时间,而不是我想要做的)。但是,我想要一个基于版本号的文件。 p>
对于我现在工作的项目,我写了一个Perl脚本,从顶层运行 svnversion -n
我的工作副本的大多数目录,并将最新的版本信息输出到.h文件(我实际上将其与工作副本中非版本化文件中的已保存的版本进行比较,以便在每次编译时不会覆盖当前修订版本信息但是你是否选择这样做取决于你。)这个.h文件(或许多文件,如果必要,取决于你的方法)在我的应用程序代码和资源文件中被引用, d喜欢它。
此脚本作为预构建步骤运行,以便在构建启动之前一切都是最新的,并且相应的文件自动重建由您的构建工具。
I'd like my .exe to have access to a resource string with my svn version. I can type this in by hand, but I'd prefer an automated way to embed this at compile time. Is there any such capability in Visual Studio 2008?
I wanted a similar availability and found $Rev$ to be insufficient because it was only updated for a file if that file's revision was changed (which meant it would have to be edited and committed very time: not something I wanted to do.) Instead, I wanted something that was based on the repository's revision number.
For the project I'm working on now, I wrote a Perl script that runs svnversion -n
from the top-most directory of my working copy and outputs the most recent revision information to a .h file (I actually compare it to a saved reversion in a non-versioned file in my working copy so that I'm not overwriting current revision information at every compile but whether you chose to do so is up to you.) This .h file (or a number of files if necessary, depending on your approach) is referenced both in my application code and in the resource files to get the information where I'd like it.
This script is run as a pre-build step so that everything is up-to-date before the build kicks off and the appropriate files are automatically rebuilt by your build tool.
这篇关于在Windows应用程序中在编译时嵌入SVN修订版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!