Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the build number of a Visual Studio project to increment?

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")
like image 725
B. Clay Shannon-B. Crow Raven Avatar asked Oct 20 '22 20:10

B. Clay Shannon-B. Crow Raven


1 Answers

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.

like image 98
razcor Avatar answered Oct 22 '22 20:10

razcor