views:

75

answers:

1

I've browsed through some of the discussion on auto-incrementing build numbers, but in the impatience of youth decided to roll my own and re-invent the wheel. I know there are probably better ways to go about this (which I'm definitely going to investigate), but my question centers more around the Assembly and/or Version classes.

My approach was to write a separate exe (BuildIncrementer) that takes a command line parameter for file name, does a regex match on the contents to grab the [assembly: AssemblyVersion...] string, do the modifications that I want (increment the build number, etc.), then write the contents back to the file. This approach works as-is.

The next thing I did was in the project that I wanted to use this on, I set up a pre-build command line that is simply the command to execute that BuildIncrementer.exe on this project's AssemblyInfo.cs file. This too works, updating the assembly info as desired.

The problem comes when I run the project, it sends an email containing the current version, obtained with Assembly.GetExecutingAssembly().GetName().Version.ToString(). BUT, the version showing up is the previous version. When my AssemblyInfo.cs says [assembly: AssemblyVersion("1.0.2.49667")], I get sent 1.0.1.45660, which was the previous build.

Anyone have any ideas why that might be?

A: 

I think your exe runs before your entire build process gets completed(or gets started) hence reflecting an old vesion...maybe

taher chhabrawala
This happens even if I build the project, double-check the AssemblyInfo file (and see the updated version), and then start the exe. Are you saying that maybe the exe is getting built before the pre-build is complete? Doesn't that kind of defeat the purpose of a pre-build command?
awshepard