4

Closed

AssemblyInfo task does not parse assembly versions correctly

description

The AssemblyInfo task uses a regular expression that's written to look for a version of the form major.minor.build.revision, however it is valid for an assembly version to contain only major.minor.build or even only major.minor. This means the regex fails on the last 2 types of version, even though they are valid and the System.Version class successfully parses them. Additionally, the task cannot parse non-numeric version numbers consisting of the character * which is a valid specifier in an [AssemblyVersion] or [AssemblyFileVersion] attribute.
 
I've written a patch to overcome the above limitations. Versions without full version numbers will have the missing ones defaulted to zero, so major.minor will become major.minor.0.0. Versions with * as a version number (only valid in revision or build fields) will have that * replaced with 0, so major.minor.* will become major.minor.0.
 
Since the AssemblyInfo task has not changed between 3.5.x and 4.0.x of the Extension Pack, this patch will be applicable to both versions.
 
Please advise to whom I should submit this patch and in what format it should be supplied in (as a diff, etc.).

file attachments

Closed Aug 23, 2012 at 4:22 PM by mikeFourie

comments

mikeFourie wrote Feb 7, 2012 at 8:03 AM

can you attach the cs file here please.

thanks

mike

IanKemp wrote Feb 7, 2012 at 11:49 AM

I've added additional validation because only AssemblyVersion allows the wildcard character. AssemblyFileVersion can legally be any string (this triggers compiler warning CS1607, but csc still builds and embeds the string) but this causes this task to fail to execute. As a workaround I've wrapped the updating of AssemblyFileVersion in a try-catch that skips updating it if an ArgumentException (indicating a non-version version number) is thrown.

Updated files attached.

IanKemp wrote May 21, 2012 at 11:21 AM

Please advise when this fix will be merged into the main branch.

mikeFourie wrote Jul 3, 2012 at 4:03 PM

Thanks Ian. Sorry for the delay. I'll get time to process this in around 3 weeks and expect to ship with the September release.

Mike

wrote Aug 23, 2012 at 4:22 PM

Resolved with changeset 79072.

mikeFourie wrote Aug 23, 2012 at 4:24 PM

Ian, thanks for the fix. Please let me know if the latest code works for you. Integrated here: http://msbuildextensionpack.codeplex.com/SourceControl/changeset/79072

Mike