Is it possible to change the format of a C # project version?

Instead of the format major.minor.build.revision, I would like to use the 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?

+4
source share
5 answers

You can put all the numbers you need (until they overflow with the data types that contain them in memory) and name them as you like. I am not sure why you would like to do this, however, since the standard format usually has some form of date stored in the assembly 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 a build from version 5.1 of the library, built on July 29, and was the first build of the day. Subsequent assemblies on the same day simply increase the scope of the review.

+10
source

The easiest way is to write your own build task that handles this, and then pass the .csproj file to your task in order to update it using the default rules. There, the article on uses the custom MSBuild task to increase version numbers , which can serve as a guide. We did a similar thing in the past and found that it works well.

I do not believe that there are tools for this included in VS2005.

+3
source

I would advise sticking to the existing scheme for version numbers used by AssemblyVersion , etc. β€œThey have well-known meanings, and this can prevent people from going against them.”

However, you can easily create your own build level attribute and use it for your date / time. Unfortunately, the DateTime type cannot be embedded in metadata, so you are probably best off using a string, but your attribute can convert this to a DateTime for you at runtime.

+1
source

You can create the appropriate assemblyinfo code snippet in the assembly script - it's easy enough using IronPython or F # as a scripting tool.

0
source

If you want 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 also be launched from the command line.

0
source

All Articles