使用MSBuild用正则表达式更新版本号
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用MSBuild用正则表达式更新版本号相关的知识,希望对你有一定的参考价值。
This snippet replaces all three different version strings in file `verid.h` using regular expressions with the value of properties `$(Major)`, `%(Minor)`, `$(SP)` and `$(Build)` when the property `$(Label)` has value _true_.To run this project you need MSBuild and the open source tasks library for MSBuild by [tigris.org](http://msbuildtasks.tigris.org/ "tigris.org").
Here is an example of file `verid.h`:
// File version
#define szVerId_IDS_VERSION "1.40 (00) - Build (26)"
#define szVerId_FILEVERSION "1.40.00.26"
#define VerId_FILEVERSION 1,40,00,26
// Product version
#define szVerId_PRODUCTVERSION "1.40.00.26"
#define VerId_PRODUCTVERSION 1,40,00,26
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <Target Name="WriteToFile" Condition="'$(Label)' == 'true'"> <FileUpdate Files="$(SVN_LocalPath)QtHmiIncludeverid.h" Regex="(d+).(d+).(d+).(d+)" ReplacementText="$(Major).$(Minor).$(SP).$(Build)" /> <FileUpdate Files="$(SVN_LocalPath)QtHmiIncludeverid.h" Regex="(d+),(d+),(d+),(d+)" ReplacementText="$(Major),$(Minor),$(SP),$(Build)" /> <FileUpdate Files="$(SVN_LocalPath)QtHmiIncludeverid.h" Regex="(d+).(d+)s((d+))s-sBuilds((d+))" ReplacementText="$(Major).$(Minor) ($(SP)) - Build ($(Build))" /> </Target> </Project>
以上是关于使用MSBuild用正则表达式更新版本号的主要内容,如果未能解决你的问题,请参考以下文章
spring cloud: zuul: 正则表达式匹配其他微服务(给其他微服务加版本号)