If you want to read the value of AssemblyInformationVersion from the actual binary assembly file, your question, how it is currently written, suggests that it is (alluding to GetAssemblyIdentity -task).
If so, just use FileVersionInfo.GetVersionInfo and read the ProductVersion property. To call this from within MSBuild, you probably need a small custom task that does this.
Internally, this is what the C # compiler turns AssemblyInformationalVersion into .
If you need to analyze the source code (for example, AssemblyInfo.cs ) for its value (this is a completely different thing!), And the Regex approach to which you are attached is not universal enough for your purposes, you will have to resort to using Roslyn or whatever or any other technology that really understands C # and can correctly analyze the source code.
source share