Versioning Build numbers with TortoiseSVN

2019-04-15 09:16发布

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...

3条回答
爷的心禁止访问
2楼-- · 2019-04-15 09:25

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
查看更多
成全新的幸福
3楼-- · 2019-04-15 09:45

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.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-04-15 09:51

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

查看更多
登录 后发表回答