If you want to read the AssemblyInformationVersion
value from the actual assembly binary, your question, as it is currently written, suggests this is the case (hinting at the GetAssemblyIdentity
-task).
If so, just use FileVersionInfo.GetVersionInfo
and read the ProductVersion
property. To invoke this from inside MSBuild you probably need a small custom task, that does that.
Internally, that is what the C# compiler turns the AssemblyInformationalVersion
into.
If, you need to parse the source code (e.g. of AssemblyInfo.cs
) for its value (which is a totally different thing!) and the Regex-approach you linked to is not versatile enough for your purposes, you'll have to resort to using Roslyn, or some other technology that actually understands C# and can properly parse the source code.