Search code examples
msbuildinstallationwindows-installer

How to read the assemblyversion from assemblyInfo.cs?


Hii, there are many others had already post so many question about this..But here the scenario is different.

I need to extract the first three digits ie. $(major).$(Minor).$(Build) from version number. how can i do this??..i tried AssemblyInfo Task..but that task is just for overwriting the version number.not to extract the version number.

I need to extract first three number and assign them to some property.for further use.

well,i can overwrite them using FileUpdate task.like ::

<FileUpdate 
    Files="@(AssemblyFile)" 
    Regex='(\d+)\.(\d+)\.(\d+)\.(\d+)' 
    ReplacementText='$1.$2.$3.$(Revision)'>
</FileUpdate>

now how can i use their value ie. $1,$2,$3 to assign to properties.???

Thanx.


Solution

  • The only solution is to write a custom build task, and parse the version number manually in the code.