Instead of the major.minor.build.revision format, I'd like to use date and time for version numbers. Something more like day.month.year.time. Is there a way to change the format of the AssemblyVersion attribute in AssemblyInfo.cs?
You can put whatever numbers you want in there (as long as they don't overflow the data types that contain them in memory) and call them whatever you wish. I am not sure why you would want to do this, however, as the standard format usually has some form of the date stored in the build field.
For example, here is the assembly version format that we use where I work:
5.1.729.1
This tells me that this is an assembly from version 5.1 of the library, built on July 29th, and was the first build of the day. Subsequent builds on the same day simply increment the revision field.
The easiest approach is to write you own build task that handles this and then have the .csproj file call your task to update it with your default rules. There's an article on using a custom MSBuild task to increment version numbers that could serve as a guide. We have done a similar thing here in the past and found it to work well.
I don't believe there are any tools included in VS2005 for doing this, though.
You could build the relevant fragment of assemblyinfo code in a build script -- it's easy enough using IronPython or F# as a scripting tool.
If you would like to automatically change these versions with a script or something similar. I would suggest using http://www.codeproject.com/KB/macros/versioningcontrolledbuild.aspx
It can be ran from the command line also.
I would suggest sticking to the existing scheme for the version numbers as used by AssemblyVersion
etc - they have well-known meanings and it might confuse people to go against them.
However, you can easily create your own assembly-level attribute and use that for your date/time. Unfortunately the DateTime
type can't be embedded in metadata so you'd probably be best off using a string - but your attribute could convert that to a DateTime
for you at execution time.