Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you add an <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.assemblyversionattribute.aspx" rel="noreferrer">AssemblyInfo</a> class to your project and amend the AssemblyVersion attribute to end with an asterisk, for example:</p> <pre><code>[assembly: AssemblyVersion("2.10.*")] </code></pre> <p>Visual studio will increment the final number for you according to <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx" rel="noreferrer">these rules</a> (thanks galets, I had that completely wrong!)</p> <p>To reference this version in code, so you can display it to the user, you use reflection. For example,</p> <pre><code>Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new DateTime(2000, 1, 1) .AddDays(version.Build).AddSeconds(version.Revision * 2); string displayableVersion = $"{version} ({buildDate})"; </code></pre> <h2>Two important gotchas that you should know</h2> <h3>From @ashes999:</h3> <p>It's also worth noting that if both <code>AssemblyVersion</code> and <code>AssemblyFileVersion</code> are specified, you won't see this on your .exe.</p> <h3>From @BrainSlugs83:</h3> <p>Setting only the 4th number to be <code>*</code> can be bad, as the version won't always increment. The 3rd number is the number of days since the year 2000, and the 4th number is the number of seconds since midnight (divided by 2) [IT IS NOT RANDOM]. So if you built the solution late in a day one day, and early in a day the next day, the later build would have an earlier version number. I recommend always using <code>X.Y.*</code> instead of <code>X.Y.Z.*</code> because your version number will ALWAYS increase this way.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload