Just open AssemblyInfo.cs file in your project, set your assembly version to major.minor.* (for example: 0.4.*). When you build your project the version will be generated automatically.
Note that in AssemblyInfo.cs as shown below, you can specify all the version values or you can default the Build and Revision Numbers by using the '*'.
Code:// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.4.*")]
The build and revision numbers are generated based on the date using the unix epoch. The build is based on the current day, and the revision is based on the number of seconds since midnight, ie. build.revision = date.time.
You have to remove the AssemblyFileVersion. Removing AssemblyFileVersion allows the version to update.
To get the version information, you can use the Application or Environment objects in Windows Forms, for example, Environment .Version.ToString().
Code:Environment.Version.Major;
Environment.Version.Minor;
Environment.Version.Build;
Environment.Version.Revision;
Environment.Version.MajorRevision;
Environment.Version.MinorRevision;
However, in .net, it's expected that the major version starts from 1. If the major version is set to 0, Environment.Version.Major may become 2. In this instance, you can get version information using reflection on your assembly:
Code:
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Reflection.AssemblyName myAssemblyName = myAssembly.GetName();
Version ver = myAssemblyName.Version;
Related:
How to Remove Previous Version with Windows Installer