tags:

views:

74

answers:

1

Is it possible to get Inno Setup to read the file version of the main executable file and set the name of the created setup to something like "myapp_setup_1_0_3708_19805.exe"?

+5  A: 

You should be able to it like this:

(I haven't tried this recently but it certainly worked back in 2007 when I was using InnoSetup in this way. It might need some slight changes if Inno's syntax has changed since then.)

#define MainBinaryName  "MyMainFile.exe"
#define SetupBaseName   "setup_mytool_"
#define AppVersion      GetFileVersion(AddBackslash(SourcePath) + MainBinaryName)
#define AVF1            Copy(AppVersion, 1, Pos(".", AppVersion) - 1) + "_" + Copy(AppVersion, Pos(".", AppVersion) + 1)
#define AVF2            Copy(AVF1,       1, Pos(".", AVF1      ) - 1) + "_" + Copy(AVF1      , Pos(".", AVF1      ) + 1)
#define AppVersionFile  Copy(AVF2,       1, Pos(".", AVF2      ) - 1) + "_" + Copy(AVF2      , Pos(".", AVF2      ) + 1)

[Setup]
OutputBaseFilename={#SetupBaseName + AppVersionFile}

If MyMainFile.exe was version 1.2.3.4 then that should call the finished installer setup_mytool_1_2_3_4.exe

The AVF1, AVF2, etc. stuff is just there to replace the dots (.) in the version number with underscores (_) to avoid causing problems with things that can't cope with lots of dots in a filename.

Leo Davidson
beautiful! worked well, just needed the MainBinaryName in quotes :) ( I edited your answer)
Keith Nicholas
+1, I didn't know the preprocessor could be used for that. Will be removing my answer.
mghie