5

Why does building a project in Visual Studio not increment the Build number?

I've got this in AssemblyInfo.cs:

[assembly: AssemblyVersion("1.5.*")]

...and this in frmAbout's constructor:

Version versionInfo = Assembly.GetExecutingAssembly().GetName().Version;
String versionStr = String.Format("{0}.{1}.{2}.{3}", versionInfo.Major.ToString(), versionInfo.Minor.ToString(), versionInfo.Build.ToString(), versionInfo.Revision.ToString());
lblVersion.Text = String.Format("Version {0}", versionStr);

Yet, after making a change to the code, and building the project (right-click project name > Build), the Build portion of the versionInfo is not incremented. The label in the "About box" goes from:

Version 1.5.5465.25383

...to:

Version 1.5.5465.25999

Why hasn't the build number increased from 5465 to 5466? And why does "Revision" jump 616 notches? Is that latter just a random value, or the number of bytes that have changed in the source, or what?

So how can I get the build number to actually increment?

UPDATE

Yep, razcor is right, as this shows "5465" (today, YMWV any day after this):

DateTime startDate = new DateTime(2000, 1, 1);
DateTime todaysDate = DateTime.Today;
int diffDays = (todaysDate.Date - startDate.Date).Days;
MessageBox.Show(diffDays.ToString());

And, knowing the build number (such as 5465), the build date can be computed and displayed:

DateTime computedDate = startDate.AddDays(diffDays);
MessageBox.Show(computedDate.ToLongDateString()); // shows today's date (such as what it is today, namely: "Thursday, December 18, 2014")
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

3

When you replace the '0' with the '*' build number and revision number will autoincrement, but not in the way you (and I) could think. Rules of this autoincrement is: build number is the number of days since 1.1.2000 and revision is the number of seconds since midnight, divided by 2.

razcor
  • 355
  • 2
  • 11
  • 1
    That's insane, if true (or even if not)! So if I do a build Monday, it will be 5469, but even I do 50 more builds that day, the Build # won't increment to 5470 until a build is made on Tuesday - or does it even need to be a new build? You may be right, but as I said, that's nuts. Nuts to the cat who came up with that methodology/logic! – B. Clay Shannon-B. Crow Raven Dec 18 '14 at 23:25
  • The good thing about that wackiness is that you can deduce/compute the date of the build. What would seem better to me, though, would be to have made the Revision the date value, and the Build number should actually increase with each build (or name it something else, by Jiminy!) – B. Clay Shannon-B. Crow Raven Dec 18 '14 at 23:42