I try to use the macros / variables in the following way, but then I get an error. Can you advice please?
#define AnnotateDir "C:\Users\new_skin\Annotate\project"
#define AnnotateUserInstallAppData "{userappdata}\Annotate3"
[Files]
Source: {AnnotateDir}\bin\gm_annotate.exe; DestDir: {app}; Flags: ignoreversion external
You are missing # char before the variable name which is used to emit defined variable value during script preprocessing stage. You can fix your script this way:
#define AnnotateDir "C:\Users\new_skin\Annotate\project"
[Files]
Source: {#AnnotateDir}\bin\gm_annotate.exe; DestDir: {app}; Flags: ignoreversion external
It looks quite misleading, but e.g. the {app} constant will remain after preprocessing whilst your defined variable will be replaced by its value, so that's why they have different notation in script.
Related
During install I try to copy existing files from a folder defined in the registry. I use some user constants to find this folder.
Yet the constant doesn't seem to be expanded (is that a word?) and get the error unknown constant '#RegKey'.
Is there a way around this or do I have to code something in Pascal?
#define Version "2.0"
#define RegKey "MyExe v" + Version
[Setup]
// various stuff
[Files]
Source: {reg:HKLM64\SOFTWARE\MyCompanyData\{#RegKey},Path|\MyCompanyData\MyExe v1.0}\*; DestDir: {app}; Flags:external recursesubdirs onlyifdoesntexist
So sorry, pebkac, typing mistake in reg key :( And got deceived by the above mentioned glitch in the IDE Inno Setup - inconsistent (preprocessor / debugger) behavior for string variable with defined symbol inside
Thanks Martin for your help
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";
Is there a way to dynamically fill the [Dirs] and [Files] sections of an Inno Setup script?
Here is what I am trying to do:
during the install process, the user will select foo (foo matches a repository to get from our SCM)
Setup will run a batch to checkout foo from our SCM
then the content of foo must be added to the [Dirs] and [Files] sections of the script
Everything works fine except for the last step. I searched around and couldn't find explanations on how to do this. I have the feeling that my script should embed all the repositories of our SCM to then be able to copy only the selected ones to the destination directory.
Thanks for your help!
Regards,
See Inno Setup Prompt for external file location.
And add the recursesubdirs flag.
You may also need the createallsubdirs flag (assuming from your reference to the [Dirs] section).
[Files]
Source: "{code:GetScmPath}"; DestDir: "{app}"; \
Flags: external recursesubdirs createallsubdirs
[Code]
function GetScmPath(Param: string): string;
begin
Result := { make it return path to the checked out files }
end;
I have an issue with ExtractTemporaryFiles while extracting *.sql files
I don't always have SQL scripts inside [Files] section to extract as mentioned below. My problem is ExtractTemporaryFiles('*.sql') raises an exception if no sql files are included with the installation.
Internal error: ExtractTemporaryFiles: No files matching "*.sql" found.
I can use try:except or another ugly way like, including a dummy.sql with the installation always. So I can make sure ExtractTemporaryFiles has a file to extract it always.
But I want to know What is the best way of avoiding exception in this case?
[Files]
Source: "Input\SQLSCRIPTS\*"; DestDir: "SQLSCRIPTS"; Flags: ignoreversion dontcopy skipifsourcedoesntexist
You can use a preprocessor to conditionally skip the ExtractTemporaryFiles call:
#if FindFirst("Input\SQLSCRIPTS\*.sql", 0)
ExtractTemporaryFiles('*.sql');
#endif
I am trying to figure out how to rename a file in the file section while building the setup file.
I want to include a Local.config file but extract it as Local.config.tmp
I can't figure out why Inno Setup keeps creating folders instead of renaming files. So far I have this, but it keeps creating folders named Api\Local.config.tmp.
Any ideas?
[Files]
Source: "Api\Local.config"; DestDir: "{app}\Api\Local.config.tmp"; Flags: ignoreversion recursesubdirs
It's creating a folder as that's what you told it to do.
Try specifying a destination name:
[Files]
Source: "Api\Local.config"; DestDir: "{app}\Api\"; DestName: "Local.config.tmp"; Flags: ignoreversion recursesubdirs