1

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.

Chris
  • 439
  • 7
  • 15
  • 1
    It's possible. But what if you rather [automatically set the version of your installer according to your application version](https://stackoverflow.com/q/6498750/850848)? – Martin Prikryl Nov 06 '18 at 07:07
  • Due to processes in place already, setting the installer version based on the application version is not an option. – Chris Nov 07 '18 at 16:13

1 Answers1

1

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.

Slappy
  • 5,250
  • 1
  • 23
  • 29