Reading AssemblyInformationalVersion value from AssemblyInfo file with RegEx

I am trying to read AssemblyInformationalVersion from an AssemblyInfo file with msbuild, but still fail. Below I get the numbers, but I need the full input inside the 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?

+1
source share
1 answer

If you just want the contents of quotes, you should grab it with the following expression:

(?<=\[assembly: AssemblyInformationalVersion\(").*(?="\)\])

I assume you can use positive lookahead / lookbehind in msbuild regexes.

A positive look and a look respectfully:

Match this(?=Where this is present ) (?<=Where this is present )Match this

+1
source

Source: https://habr.com/ru/post/1270011/


All Articles