Retrieving version info from AssemblyInfo.cs in NAnt

I found a fairly neat way to retrieve version details from an AssemblyInfo.cs file without having to go down the script task route, here’s the nant xml:

This will put the version segments into the named properties.

Some info I picked up while using the regex task which I couldn’t find documentation about:

  1. When having to match on double quote character ” you must use the ascii code \x22
  2. The names of the groups in the regex can’t contain periods, at first i had the groups named version.major, version.minor etc…

2 thoughts on “Retrieving version info from AssemblyInfo.cs in NAnt

  1. one efficiency note, however… you should escape your periods in the build number regex, otherwise, it’s doing a greedy match then backtracking to the next number sequence. so, the regex should be

    Thank you again, though.

Comments are closed.