views:

362

answers:

5

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?

+6  A: 

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.

Andrew Hare
Scott Ivey
It's not an easily discernible format, though. It would be nice for that version to automagically increment the way it does now, just using dates and times instead of build numbers. I guess I should have worded the question better: I'd like to change the format of the auto-generated version numbers.
Lee Crabtree
Woah, should have read the other comment before adding my own. That's exactly what I needed, Scott.
Lee Crabtree
an alternative is to use 9210 as the build number 9 is the current year and 210 the day of the year. This gives you a little more time before buildnumbers repeat. See also: http://www.paulvanbrenk.com/buildday/
pb
+3  A: 

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.

jsight
A: 

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.

Steve Gilham
A: 

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.

Ryan
A: 

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.

Jon Skeet