1
votes

I'd like to add a check in Inno Setup to ensure that my exe file version always matches the version of the installer. Is there a way to do this via the preprocessor?

So the idea is that if the exe version doesn't match the version I set in Inno Setup, that it aborts the compile.

1
Due to processes in place already, setting the installer version based on the application version is not an option.Chris

1 Answers

1
votes

Define your version and compare the .exe file against it with GetFileVersion() preprocessor command:

#define Version "1.5.0.0"

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
#if (GetFileVersion("MyProg.exe") != Version)
#error File version does not match!
#endif 

"#error" stops the compilation and shows message.

This is modified Example1.iss from Inno Setup Examples directory.