Creating a file with build number and branch name in SVN

这一生的挚爱 提交于 2019-12-02 01:47:06

Here is a full breakdown of how I did it

Create a blank text document in the root of your website called Version.txt.

Create a second text document in the root of your website called Version.tmpl with the following contents

Revision:   $WCREV$
Repository: $WCURL$
Modified:   $WCMODS?Yes:No$
Built On:   $WCNOW$

Right click on your website project and choose properties. Then go to the build events tab.

Paste the following into your post build events:

cd $(ProjectDir)
"%ProgramFiles%\TortoiseSVN\bin\SubWCRev.exe" ..\. Version.tmpl Version.txt

This will update the Version.txt file with some details about the working copy, using Version.tmpl as the template. The fact that Version.txt is now included in your website means that every time the website is deployed the Version.txt is also deployed and will contain useful information should you ever need to get your codebase back to the deployed version.

svnversion is tool for checking current revisions of a working copy.

On Windows you have Subwcrev.

You might be able to do it with a build script. Look at the .svn\entries file in the root of the repository. It should contain the revision number early on in the file (line 5 or so)

You can use this code get the information from vb. I use a rewritten version of this to find out this information at app startup time.

http://www.codeproject.com/KB/architecture/svn_visual_studio.aspx

I use ant as my build tool, so I have an ant target that stores the output of svnversion in the file svn-version. That target is a dependency of all the major entry points, so every time I run ant, svn-version is updated. I have the packaging operations include svn-version in all deliverable tar and zip files. So I can always look in svn-version to find out what version of code has been installed.

Whatever build tool you are using, you should be able to do the same. if the data from svnversion isn't sufficient, you may want to add the output of svn info to the file as well.

I also use Ant and have developed a special Task that is able to retrieve the Subversion information from a local repository (if the code was checked-out) or a remote Subversion server (if the code was exported) and makes them available via regular Ant properties.

Using Ant replacement mechanism (in the Copy task, for example), you can place these values wherever you see fit.

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