0

Is it possible to get the number of times the application has been compiled to represent an accurate build number in C#? So the first time you compile and run the app it should say 1. Then on the second 2, and so on. I'm looking for something built in, I don't want to keep track in a file or anything.

I basically want this, but I want it to auto-increment each time it's compiled.

Assembly assembly = Assembly.GetExecutingAssembly();
int buildNumber = assembly.GetName().Version.Build;
bwoogie
  • 4,339
  • 12
  • 39
  • 72
  • Do they have to be consecutive? (why?) Projects are usually compiled many, many times during development, so it seems like an odd requirement since you won't release every time the project is built. – D Stanley Aug 03 '17 at 22:05
  • If the build numbers don't need to be consecutive, see [this answer](https://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio) – D Stanley Aug 03 '17 at 22:06
  • Take a look at this question. It should give you an answer : https://stackoverflow.com/questions/356543/can-i-automatically-increment-the-file-build-version-when-using-visual-studio – Piotr Aug 03 '17 at 22:38
  • Yeah, I'd like them to be consecutive, not the arbitrary date which using [assembly: AssemblyVersion("1.0.*")] gives you. – bwoogie Aug 03 '17 at 23:10

1 Answers1

0

There doesn't appear to be a built in way of doing this, however there is an extension to automatically increment the version number.

https://marketplace.visualstudio.com/items?itemName=PrecisionInfinity.AutomaticVersions

bwoogie
  • 4,339
  • 12
  • 39
  • 72