Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change only Revision number in AssemblyInfo.cs with MSBuild FileUpdate task

I need to change only the revision number of an AssemblyInfo.cs file. The version number is in the format Major.Minor.Build.Revision e.g. 1.4.6.0.

Currently I change the version with the FileUpdate task (from the MSBuild Community Tasks Project) and the following regex:

<FileUpdate Files="@(AssemblyResult)"
    Regex='(\[\s*assembly:\s*AssemblyVersion\(\s*"[^\.]+\.[^\.]+)\.([^\.]+)(\.)([^\.]+)("\)\s*\])'
    ReplacementText='[assembly: AssemblyVersion("$(AssemblyMajorNumber).$(AssemblyMinorNumber).$(AssemblyBuildNumber).$(Revision)")]' />

Now I need to update only the revision number and leave major,minor and build unchanged. So, is there any task to do this? Or can it be done with a regex? What would be the regular expression then?

like image 976
Divya mohan Singh Avatar asked Jan 08 '10 08:01

Divya mohan Singh


1 Answers

How about this:

<FileUpdate Files="Properties/AssemblyInfo.cs"
   Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
   ReplacementText="$1.$2.$3.$(Revision)" />
like image 82
Wim Coenen Avatar answered Oct 05 '22 19:10

Wim Coenen