About Me

My photo
Software Developer and ideas man!

Thursday, June 11, 2015

Ant Regex for updating SCOM MP version information in mpproj file

One think I had fun doing today was using ant's Perl v5 regex expressions to write in the version info of our build process into the SCOM Management Pack prior to building with MSBuild - I could have used the auto-increment feature of VSAE but this would not have been synchronized with the ant build properties we use for our other binaries that is part of a wider build deployment.

So, looking for a solution I thought I'd explore ant's regexs - the statement below works by matching on the version xml tags and groups them along with existing version info before substituting in the ant version properties used as part of the wider build process in the management pack project file.  

 <replaceregexp file="${SCOM.dir}/Pauls.mpproj"                     
byline="true"
match="(<Version>)([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)(<\/Version>)"
replace="\1${VersionMajorNo}\.${VersionMinorNo}\.${VersionPatchNo}\.${VersionBuildNo}\3"/>

So
  1.0.0.5
becomes
  11.2.0.278

No comments:

Post a Comment