In Visual Studio 2008 (and possibly other versions) when you create a C# project in many cases the wizard also creates the AssemblyInfo.cs file for you. That's quite handy but it can also come with a surprise caused by a subtle difference.
Usually both the AssemblyFileVersionAttribute and the AssemblyVersionAttribute are created for you. The generated code looks as follows:
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
The issue that you may run in is that when you read the comment and infer that it applies to both AssemblyVersion and AssemblyFileVersion. That is not the case!
AssemblyVersion can deal with wild cards as the generated comment suggests. For AssemblyFileVersion "
wild cards are not supported".
There is a solution however. If you simply remove the AssemblyFileVersion, the
version will be picked up from AssemblyVersion. as the Win 32 file version. And for AssemblyVersion you can use wild cards. In that case your code in AssemblyInfo.cs would look like this:
[assembly: AssemblyVersion("1.0.*")]
// No wild cards for AssemblyFileVersion!
//[assembly: AssemblyFileVersion("1.0.0.0")]
// Since AssemblyFileVersion is commented out AssemblyVersion
// will be used for Win 32 file version.
So the recommendation is: Comment out AssemblyFileVersion unless you can't get away without it.
1 comments:
Thanks for the info Manny. This was really puzzling me. I've put a pointer to this on my blog (http://blogs.msdn.com/b/bluecollar/archive/2011/01/12/assemblyfileversionattribute-and-assemblyversionattribute-a-subtle-difference.aspx).
Post a Comment
All comments, questions and other feedback is much appreciated. Thank you!