I'm trying to read the AssemblyInformationalVersion from the AssemblyInfo file with msbuild but I am failing so far. The below one gets me the digits but I need to whole input inside quotes:
<PropertyGroup>
<Pattern>\[assembly: AssemblyInformationalVersion\(.(\d+)\.(\d+)\.(\d+)</Pattern>
<In>@(ItemsFromFile)</In>
<Out>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern)))</Out>
</PropertyGroup>
<Message Text="Output : $(Out.Remove(0, 41))"/>
This is the target line for example:
[assembly: AssemblyInformationalVersion("0.3.0-pre01")]
Any idea?
If you just need the contents of the quotes you should be able to grab it with an expression like this:
(?<=\[assembly: AssemblyInformationalVersion\(").*(?="\)\])
I presume you can use positive lookahead/lookbehind in msbuild regexes.
Positive lookahead and lookbehind respectivly:
Match this(?=Where this is present ) (?<=Where this is present )Match this