GetAssemblyIdentity task seems to return me only AssemblyVersion, not AssemblyInformationalVersion.
I can parse AssemblyInfo.cs, as suggested by here Reading AssemblyInformationalVersion value from AssemblyInfo file with RegEx but I don't think this is optimal solution.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With