In many situations, you will need to have an auto-increased version number in assembly for your project. For example, if you are developing or updating a NuGet package for one or multiple projects sharing. Every time when you update the package you will need to change the version number so that the projects using this package will be able to update the package to the latest version. In stead of changing the assembly version number manually on each build, Visual Studio can do this for you automatically.
The solution is to go to Project Properties -> Application, click the button named “Assembly Information…”
Then in the Assembly Information windows, change the 3rd box for version information to “*”, then click OK.
Now each time when you build the solution or project, it will generate a version number like 1.0.X.Y, where X is the number of days from year 2000/1/1 and Y is the number of seconds from midnight divided by 2.
If you the “*” at the 4th box in the above step, the version will be generated as 1.0.0.Y where Y is the number of seconds from midnight. This may cause versioning issue. For example, when the last version was build in afternoon yesterday (e.g. Y=15000, version is 18.104.22.16800) and the new version is built today morning (Y=8000, the version number will be 22.214.171.12400), then the new version number is smaller than the old version.
Finally, you could also achieve the same by modifying the AssemblyInfo.cs file directly if this is preferred. Just to change or add the below two lines in the file.
[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.*")]
If you encounter an error “a wildcard is not allowed in this field” for File Version. The solution is to empty all 4 boxes in the File Version row. That way the File Version will be generated same as the Assembly version. If you edit the AssemblyInfo.cs file, you could delete the line for AssemblyFileVersion.
More about the version number: https://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx
More about setting up auto-version number: https://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio
More about the wildcard-not-allowed error: https://stackoverflow.com/questions/356543/can-i-automatically-increment-the-file-build-version-when-using-visual-studio