inno-setuppreprocessor

Why preprocessor behaves differently in #include directive then in [Files] section Inno Setup script


Was trying to understand the difference between a syntax that would include another script file and a source file in Inno Setup script while using macros to search and find files.

I have tried to use FindFolder function from Find a directory using wildcard in Inno Setup:

#define FindFolder(Path) \
    Local[0] = FindFirst(Path, faDirectory), \
    Local[0] ? AddBackslash(ExtractFileDir(Path)) + FindGetFileName(Local[0]) : Path

Like this:

#include "{#FindFolder('..\..\..\packages\ScriptPreRequisites*')}\DotNetDependencies.iss"

Solution

  • Within # you are in the "realm" of Inno Setup preprocessor.

    There are two ways to enter preprocessor realm.

    The inline syntax is useful when you want to use preprocessor expression outside of preprocessor realm. Like in normal Inno Setup sections (or in Pascal Script code):

    [Files]
    Source: "{#FindFolder("..\packages\PackagesA*")}\*.*"; DestDir: "{app}"; \
        flags: recursesubdirs  
    

    Though in #include preprocessor directive, you are already in the preprocessor realm. And there, the {#xxx} syntax is invalid (it might even have a different [valid] meaning theoretically, but actually curly brackets have no use in preprocessor).

    The syntax of #include directive is:

    #include <expression>
    

    The preprocessor uses C-like expression syntax. So your expression in this case is:

    FindFolder('..\..\..\packages\ScriptPreRequisites*') + '\DotNetDependencies.iss'