Inno Setup Exclude only a subdirectory in tree root, but not all other subdirectories within the tree with the same name

Viewed 112

I have this in my [Files] header:

[Files]
Source: "{#PathToRepoRoot}\Development\aaa\bbb\libs\MyApp.exe"; DestDir: "{app}";  \
    Flags: ignoreversion
Source: "{#PathToRepoRoot}\Development\aaa\bbb\*"; DestDir: "{app}"; \
    Excludes: "*.pyc, {#PathToRepoRoot}\Development\aaa\bbb\Build"; \
    Flags: ignoreversion recursesubdirs createallsubdirs

It is supposed to exclude all files from the Build folder but for some reason it doesn't. I have tried changing bbb\* to bbb\ and bbb but it doesn't help. I also took a look at Inno Setup : Exclude a directory and its files also but this didn't help. The strange thing is that the .pyc files are being excluded

I found out that doing Excludes: "*.pyc, Build"; does what I want. From what I understand this will exclude all files that are named Build. In my case this is not a problem since I only have one such file. But I do prefer a more specific exclude.

1 Answers

I believe the masks in the Excludes parameter are evaluated against a relative path starting from the root folder ({#PathToRepoRoot}\Development\aaa\bbb). So you want to match just Build.

But indeed, if you use Build only as an exclude mask, it would exclude all Build files and folders anywhere in the tree, as the mask is matched against the end of the (relative) path by default. Prepend the mask with a backslash to tell Inno Setup to evaluate it against the beginning of the (relative) path:

Excludes: \Build
Related