I am trying to find version numbers in AssemblyInfo.cs files that don’t start with the Major.Minor numbers I am building. I have tried various versions of this but it doesn’t do what I want – can anyone help with my RegEx?
<MSBuild.ExtensionPack.FileSystem.File Condition="'$(BuildNumber)' != ''"
TaskAction="Replace"
RegexPattern="Version\(\"(?:![$(VersionMajor).$(VersionMinor)])\d\.\d\.\d\.\d)\"\)"
Replacement="Version("$(VersionMajor).$(VersionMinor).0.0")"
Files="$(AssemblyInfoFiles)" />
Note that I am using the AssemblyInfo class inthe extension pack but the above is for the initial set.
EDIT
Here is the working version I am using with @Omega’s help. Note that i am using a VersionMajorMinor property I already have.
<!-- Update all the assembly info files with generated version info -->
<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace"
RegexPattern="Version\(\"(?!$(VersionMajorMinor)\.)\d+\.\d+\.\d+\.\d+\"\)"
Replacement="Version("$(VersionMajorMinor).0.0")"
Files="@(AssemblyInfoFiles)" />
Try
Version\(\"(?!$(VersionMajor)\.$(VersionMinor)\.)\d+\.\d+\.\d+\.\d+\"\)