views:

19

answers:

1

I maintain a small app which is built in VC++ 2008 (a .net app) which I distribute using innosetup.

Currently I manually update the version number in the header of the main app:

static String^ m_version = "1.1";
static String^ m_build = "1";

The software puts this together internally to report v1.1.1 in this case. To do a release I then manually edit my .iss script:

#define MyAppVer "1.1.1.0"
#define MyAppVerName "MyApp v1.1.1"

OutputBaseFilename=Setup_{#MyAppName}_v{#MyAppVer}

Is there some way I can automate all ov this so I need only update the version number once?

+1  A: 

This is not the proper way to embed version info in your program. You should use a Version resource. View + (Other Windows) + Resource View. Add Resource + Version and fill in the FILEVERSION and PRODUCTVERSION properties. After you build, you can see that version when you right-click the DLL or EXE in Explorer. InnoSetup should be able to see it too, not sure.

If you need this info at runtime (About box or something like that) then use the FileVersionInfo class.

Hans Passant
Is it possible to retrieve this information from the `main` function in a CLI winforms app? I have some exception handling code in there which I normally populate with the version number so that I can record it in the event of something bad happening.
Jon Cage
As I said, use the FileVersionInfo class. Get the path to the assembly from, say, Assembly.GetEntryAssembly().Location
Hans Passant
That got it! `String^ appVersion = FileVersionInfo::GetVersionInfo(Assembly::GetEntryAssembly()->Location)->ProductVersion;`
Jon Cage