I am using the #include
preprocessor directive to include other .iss
files that contain separate components of my drivers installation.
[Files]
#include "subfolder\issComponent.iss"
and issComponent.iss
performs an installation of a driver from its own relative path.
[Files]
Source: "Driver\Driver.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
[Run]
Filename: "{tmp}\Driver.exe";
When I try to build the main/calling script, the relative path to Driver.exe
do not work due to the relative pathing being referenced from the location of the main/calling script.
The path from the issComponent.iss
resolves to
.\Driver\Driver.exe
instead of
.\subfolder\Driver\Driver.exe
since the include statement includes the file statements directly, and does not compile it from its own path. This is what is causing the error. I am wondering if there is a way to correctly use the relative paths in both locations.
The #include
is interpreted by preprocessor. The [Files]
(and other sections) are interpreted by compiler. Those are separate components which do not know about each other. Just like in C/C++. The preprocessor merges the issComponent.iss
into the main .iss
file like this:
[Files]
[Files]
Source: "Driver\Driver.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
[Run]
Filename: "{tmp}\Driver.exe";
And the the compiler won't even know that the lines were originally in a different file, let alone in a different folder.
You can make use of some preprocessor capabilities to achieve what you want. For example the __PATHFILENAME__
predefined variable, which resolves to the path to the .iss
file, where it is referenced.
#define PathToSelf ExtractFileDir(__PATHFILENAME__)
Source: "{#PathToSelf}\MyProg.exe"; DestDir: "{app}"
This will result in final .iss
script like:
[Files]
[Files]
Source: "C:\full\path\to\subfolder\Driver\Driver.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
[Run]
Filename: "{tmp}\Driver.exe";