在VS项目中使用SVN版本号作为编译版本号

1、复制版本号文件 AssemblyInfo.cs

2、把复制后的文件改名为 AssemblyInfo.templet.cs
修改内容: [assembly: AssemblyVersion("1.0.0.$WCREV$")]

3、工程右键->属性->生成事件->预生成事件命令行 输入以下代码:
"C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" $(ProjectDir) $(ProjectDir)Properties\AssemblyInfo.templet.cs $(ProjectDir)Properties\AssemblyInfo.cs -f

 

//-------------------------------------------------------------------------------------------------------------- 

 

1,svn的工具可获取版本号并更新到项目文件

如果提供了源文件和目的文件,SubWCRev 会复制源文件到目标文件,执行如下所属的关键字替换:

表 5.2. 列出可用的命令行开关

关键字描述
$WCREV$工作副本中最高的提交版本来替换
$WCDATE$用最高提交版本的日期/时间替换。默认使用国际化格式:yyyy-mm-dd hh:mm:ss。作为选择,你可以指定strftime()使用自定义格式,例如:$WCDATE=%a %b %d %I:%M:%S %p$。格式字符的列表参见在线引用
$WCNOW$Replaced with the current system date/time. This can be used to indicate the build time. Time formatting can be used as described for$WCDATE$.
$WCRANGE$在工作目录用更新版本范围替换。如果工作目录处于一致的状态,它是一个单一版本。如果工作目录包含混合版本,或者是过时,或者是故意更新到版本,那么这个范围会用象100:200这样的格式来显示。
$WCMIXED$当有混合版本时用TText替换$WCMIXED?TText:FText$,否则用FText替换。
$WCMODS$若本地存在修改,就用TText替换$WCMODS?TText:FText$,否则用FText替换。
$WCURL$用传递给SubWCRev的工作目录的版本库地址替换。
$WCINSVN$$WCINSVN?TText:FText$is replaced withTTextif the entry is versioned, orFTextif not.
$WCNEEDSLOCK$$WCNEEDSLOCK?TText:FText$is replaced withTTextif the entry has thesvn:needs-lockproperty set, orFTextif not.
$WCISLOCKED$$WCISLOCKED?TText:FText$is replaced withTTextif the entry is locked, orFTextif not.
$WCLOCKDATE$Replaced with the lock date. Time formatting can be used as described for$WCDATE$.
$WCLOCKOWNER$Replaced with the name of the lock owner.
$WCLOCKCOMMENT$Replaced with the comment of the lock.

 

SubWCRev.exe从命令行或脚本中运行,使用命令行参数控制。

SubWCRev WorkingCopyPath [SrcVersionFile DstVersionFile] [-nmdfe]

WorkingCopyPath是要检查的工作副本路径,你可以只对工作副本使用SubWCRev,而不是直接对版本库,这个路径可以是绝对路径,也可以是工作目录的相对路径。

如果你想让SubWCRev执行关键字替换,象版本库版本,地址等字段保存到文本文件,就需要提供一个模版文件SrcVersionFile,输出文件DstVersionFile就是模版替换之后的版本。

有几个开关影响 SubWCRev工作。如果使用多个,必须用单个组指定,例如要用-nm,不能用-n -m

表 5.1. 列出可用的命令行开关

切换描述
-nIf this switch is given, SubWCRev will exit withERRORLEVEL 7if the working copy contains local modifications. This may be used to prevent building with uncommitted changes present.
-mIf this switch is given, SubWCRev will exit withERRORLEVEL 8if the working copy contains mixed revisions. This may be used to prevent building with a partially updated working copy.
-dIf this switch is given, SubWCRev will exit withERRORLEVEL 9if the destination file already exists.
-f如果给出这个开关,SubWCRev 就会包含文件夹的最后修改版本。默认行为是取得版本号时只考虑文件。
-eIf this switch is given, SubWCRev will examine directories which are included withsvn:externals, but only if they are from the same repository. The default behaviour is to ignore externals.
-xIf this switch is given, SubWCRev will output the revision numbers in HEX.
-XIf this switch is given, SubWCRev will output the revision numbers in HEX, with '0X' prepended.

参考这个文档http://tortoisesvn.net/docs/nightly/TortoiseSVN_zh_CN/tsvn-subwcrev.html

转载于:https://www.cnblogs.com/zouhao/p/3446951.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值