Versioning Build numbers with TortoiseSVN

我的梦境 提交于 2019-12-06 12:29:57

问题


Multiple duplicates: https://stackoverflow.com/search?q=svnversion


I'm using TortoiseSVN with SVN Service running as a service on a windows server.

I would like the version / build number in the project to be updated as or after the project is committed. So that the correct version / build on the project will be reflected in several places such as log files, Resource tables, Help > About Etc...

Thanks...


回答1:


You can do this in the build script and other places right before you make EXEs, install files, etc -

What I did to add it to my resources/version info was make a template file for my rc file, use the macro substitution, then add a call to SubWCRev in the prebuild step of my EXE's project.

See this

SubWCRev is a tool you can use for this.

$WCREV$ is the macro that gets replaced with the current svn revision.

Each template file is in the SVN repository but the actual files that get compiled/interpreted are generated from those. So just prior to building each generated output (exe, installer, release notes, etc) you would run the subwcrev tool and replace the macros.




回答2:


You can use Revision tag.

Select one file which will contain some variable/constant with revision number. Add svn:keywords SVN property with Revision value to this file (RMB on file, TortoiseSVN->Properties->New, "svn:keywords" as name, "Revision" as value). Now inside this file every occurrence of "$Revision$" tag will be replaced with "$Revision: 7 $" for instance. Unfortunately this would be the version of this file only, so it'd have to be "touched" every time build number increases.

You can find more keywords working this way in SVN Book




回答3:


Integrate something into your build process which writes the current SVN revision into a source file (e.g. revision.h which only contains a "const int revision = xxx;") which is not under version control (svn:ignore) and include this in the build.

Here's a very simple snippet to get the idea:

echo "const int revision = `svn info | grep Revision | cut -d":" -f 2`;" > revision.h


来源:https://stackoverflow.com/questions/1142999/versioning-build-numbers-with-tortoisesvn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!