Return to Snippet

Revision: 36529
at November 23, 2010 02:06 by cappellin


Updated Code
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
	<Target Name="WriteToFile" Condition="'$(Label)' == 'true'">

		<FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
			Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
			ReplacementText="$(Major).$(Minor).$(SP).$(Build)" />

		<FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
			Regex="(\d+),(\d+),(\d+),(\d+)"
			ReplacementText="$(Major),$(Minor),$(SP),$(Build)" />

	        <FileUpdate Files="$(SVN_LocalPath)\QtHmi\Include\verid.h"
			Regex="(\d+)\.(\d+)\s(\(\d+\))\s-\sBuild\s(\(\d+\))"
			ReplacementText="$(Major).$(Minor) ($(SP)) - Build ($(Build))" />

	</Target>
</Project>

Revision: 36528
at November 23, 2010 00:00 by cappellin


Updated Code
<Target Name="WriteToFile" Condition="'$(Label)' == 'true'">

	<FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
		Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
		ReplacementText="$(Major).$(Minor).$(SP).$(Build)" />

	<FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
		Regex="(\d+),(\d+),(\d+),(\d+)"
		ReplacementText="$(Major),$(Minor),$(SP),$(Build)" />

        <FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
		Regex="(\d+)\.(\d+)\s(\(\d+\))\s-\sBuild\s(\(\d+\))"
		ReplacementText="$(Major).$(Minor) ($(SP)) - Build ($(Build))" />
</Target>

Revision: 36527
at November 22, 2010 22:52 by cappellin


Initial Code
<Target Name="WriteToFile" Condition="'$(Label)' == 'true'">
        <FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
			Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
			ReplacementText="$(Major).$(Minor).$(SP).$(Build)" />
    </Target>
    
    <Target Name="WriteToFile2" DependsOnTargets="WriteToFile" Condition="'$(Label)' == 'true'">
        <FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
			Regex="(\d+),(\d+),(\d+),(\d+)"
			ReplacementText="$(Major),$(Minor),$(SP),$(Build)" />
    </Target>
    
    <Target Name="WriteToFile3" DependsOnTargets="WriteToFile2" Condition="'$(Label)' == 'true'">
        <FileUpdate Files="$(SVN_LocalPath3)\QtHmi\Include\verid.h"
			Regex="(\d+)\.(\d+)\s(\(\d+\))\s-\sBuild\s(\(\d+\))"
			ReplacementText="$(Major).$(Minor) ($(SP)) - Build ($(Build))" />
    </Target>

Initial URL

                                

Initial Description
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

Initial Title
Update version number with Regular Expression using MSBuild

Initial Tags
regex, file, update

Initial Language
XML