Posted By

cappellin on 11/22/10


Tagged

regex file regular Expression update MSBuild


Versions (?)

Update version number with Regular Expression using MSBuild


 / Published in: XML
 

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.

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
  1. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  2. <Target Name="WriteToFile" Condition="'$(Label)' == 'true'">
  3.  
  4. <FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
  5. Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
  6. ReplacementText="$(Major).$(Minor).$(SP).$(Build)" />
  7.  
  8. <FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
  9. Regex="(\d+),(\d+),(\d+),(\d+)"
  10. ReplacementText="$(Major),$(Minor),$(SP),$(Build)" />
  11.  
  12. <FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
  13. Regex="(\d+)\.(\d+)\s(\(\d+\))\s-\sBuild\s(\(\d+\))"
  14. ReplacementText="$(Major).$(Minor) ($(SP)) - Build ($(Build))" />
  15.  
  16. </Target>
  17. </Project>

Report this snippet  

You need to login to post a comment.