inno-setup

Is it possible to generate user defined Info/Warning message from Setup section in Inno Setup?


I have the following code to display InfoBeforeFile page only if "readme" file exist in specified path, when compiling the installer.

Additionally I want to show Info/Warning message when "readme" file does not exist, while compiling.

#define readmeFile 'readme.rt'
[Setup]
#if FileExists(readmeFile)
InfoBeforeFile=notes.rtf
#else
;Is it possible to generate info message on Inno setup console when file does not exist ?
#endif

Any possible way of showing Info message from Setup section using any other sections of Inno Setup are welcome.


Solution

  • You can use #pragma warning preprocessor directive:

    #define readmeFile 'readme.rt'
    [Setup]
    #if FileExists(readmeFile)
    InfoBeforeFile=notes.rtf
    #else
    #pragma warning "Readme does not exist"
    #endif
    

    You will get this output when compiling the installer:

    [ISPP] Preprocessing.
    [ISPP Warning] (6): Readme does not exist.
    [ISPP] Preprocessed.


    There is also #pragma message.


    For clarity: This has nothing to do with Setup section. All lines with # are preprocessor directives (like in C/C++), that are processed even before Inno Setup compiler parses sections.

    When the readme file does not exist, Inno Setup compiler will see only:

    [Setup]
    

    When the readme file does exist, Inno Setup compiler will see:

    [Setup]
    InfoBeforeFile=notes.rtf