0
votes

I am trying to package everything in C:\App\Web\* into an installer.

If the database sub-folder mysql\data exists, then I do not want to replace these files.

This is my Inno Setup script:

[Files]
Source: "C:\App\Web\xampp-control.exe"; DestDir: "{app}"; Flags:     ignoreversion
Source: "C:\App\Web\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\App\Web\*"; DestDir: "{app}"; Excludes: "C:\App\Web\mysql\data\*"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: DirExists(ExpandConstant('{app}\mysql\data\*'))

The files in mysql\data still get replaced.

I want the installer to avoid overwriting the data folder if the application is already installed (i.e. performing an upgrade).

1

1 Answers

1
votes

You have two problems in your script:

  • The first entry C:\App\Web\* copies everything unconditionally. The second entry cannot change it.
  • The DirExists does not support file masks, you can use it to test existence of a directory only. Remove the trailing \*

This is the correct way:

[Files]
...

; Always install everything except the mysql\data
Source: "C:\App\Web\*"; DestDir: "{app}"; Excludes: "C:\App\Web\mysql\data\*"; \
    Flags: ignoreversion recursesubdirs createallsubdirs

; Install the mysql\data, only if it does not exist yet
Source: "C:\App\Web\mysql\data\*"; DestDir: "{app}\mysql\data"; \
    Flags: ignoreversion recursesubdirs createallsubdirs; \
    Check: not DirExists(ExpandConstant('{app}\mysql\data'))