VS2005: how to automatically generate build number with date?

3 answers

msbuildtasks did not solve my problem. As explained in the description, I need a special format. Also, the documentation for msbuildtasks is good ... find it.
I changed the source code of the AssemblyInfo Task by adding a new type of increment 'YearAndDay' with my needs:

case IncrementMethod.YearAndDay:
{
    DateTime dDate = DateTime.Now;
    long buildNumber = dDate.Year % 2000 * 1000;
    buildNumber += dDate.DayOfYear;
    string newVersionNumber = buildNumber.ToString();
    Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber);
    return newVersionNumber;
}

This seemed to be the easiest solution.

+1
source

You want to see msbuildtasks . This is an open source msbuild task suite. The module has the task of increasing / changing / etc assembly number. It is also very easy to use and super easy to expand.

+3

The default automatic build number generated by VS / C # / msbuild is the number of days since 1.1.2000, and the release number is the number of two second increments since midnight, so you can calculate the build date and time in the opposite direction:

new DateTime(2000, 1, 1).AddDays(assemblyName.Version.Build).AddSeconds(assemblyName.Version.Revision*2)
+2
source

Source: https://habr.com/ru/post/1703970/


All Articles