如何防止 Inno Setup 在创建安装程序和便携式提取器时多次添加文件

发布于 2025-01-17 23:11:27 字数 2209 浏览 0 评论 0原文

我喜欢在一个设置中创建安装程序/便携式提取器,有时我使用 .paf 便携式文件,我在 [Code] 部分中使用检查,以便安装程序知道在哪里放置文件,具体取决于安装或便携式,并且工作完美,但安装程序保留由于我的做法,将文件添加了 2 倍。我想知道是否有一种简单的方法可以阻止 Inno Setup 多次添加文件并导致安装程序过大。

示例脚本:

[Files]
;Install for x64 & x86
    Source: "{app}\shared\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: not InstallType('Portable');
    Source: "{app}\x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: isWin64 and not InstallType('Portable');
    Source: "{app}\x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: not isWin64 and not InstallType('Portable');
    
    ;Portable.PAF
    ;Source: "AppPortable.PAF\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; check: InstallType('Portable')
    Source: "AppPortable.PAF\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\shared\*"; DestDir: "{app}\App\ProgramFiles64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\shared\*"; DestDir: "{app}\App\ProgramFiles"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\x64\*"; DestDir: "{app}\App\ProgramFiles64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\x86\*"; DestDir: "{app}\App\ProgramFiles"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');

我尝试过类似的操作,但没有成功:

#If  "not InstallType('Portable')"
Source: "{app}\x64";  DestDir: "{code:GetExeLocation}"; Flags: ignoreversion; Check: not InstallType('Portable')
Source: "{app}\x86\*"; DestDir: "{code:GetExeLocation}"; Flags: ignoreversion; Check: not InstallType('Portable')
#Else
Source: "{app}\x64\*"; DestDir: "{code:GetExeLocation}\App\MyApp"; Flags: ignoreversion recursesubdirs createallsubdirs;; Check: InstallType('Portable')
Source: "{app}\x86\*"; DestDir: "{code:GetExeLocation}\App\MyApp"; Flags: ignoreversion recursesubdirs createallsubdirs;; Check: InstallType('Portable')
#EndIf

I like to create installer / portable extractors in one setup and sometimes i use .paf portables, i use a check inside the [Code] section so the installer knows where to place files depending if install or portable and that works perfectly but the installer keeps adding the files 2x due to the way i do it. I am wondering if there is a simple way to stop Inno Setup from adding files multiple times and causing a large installer.

Example script:

[Files]
;Install for x64 & x86
    Source: "{app}\shared\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: not InstallType('Portable');
    Source: "{app}\x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: isWin64 and not InstallType('Portable');
    Source: "{app}\x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: not isWin64 and not InstallType('Portable');
    
    ;Portable.PAF
    ;Source: "AppPortable.PAF\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; check: InstallType('Portable')
    Source: "AppPortable.PAF\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\shared\*"; DestDir: "{app}\App\ProgramFiles64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\shared\*"; DestDir: "{app}\App\ProgramFiles"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\x64\*"; DestDir: "{app}\App\ProgramFiles64"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');
    Source: "{app}\x86\*"; DestDir: "{app}\App\ProgramFiles"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: InstallType('Portable');

I have tried something like this with no luck:

#If  "not InstallType('Portable')"
Source: "{app}\x64";  DestDir: "{code:GetExeLocation}"; Flags: ignoreversion; Check: not InstallType('Portable')
Source: "{app}\x86\*"; DestDir: "{code:GetExeLocation}"; Flags: ignoreversion; Check: not InstallType('Portable')
#Else
Source: "{app}\x64\*"; DestDir: "{code:GetExeLocation}\App\MyApp"; Flags: ignoreversion recursesubdirs createallsubdirs;; Check: InstallType('Portable')
Source: "{app}\x86\*"; DestDir: "{code:GetExeLocation}\App\MyApp"; Flags: ignoreversion recursesubdirs createallsubdirs;; Check: InstallType('Portable')
#EndIf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪意 2025-01-24 23:11:27

如果这些文件实际上在源文件夹中重复,那么它们将被添加两次。这是 InnoSetup 的预期(和期望)行为。您可以拥有多个具有相同源但目标不同的文件。

确保两种不同安装类型之间共享的每个文件都是从同一源目录添加的。 InnoSetup 应该只添加相同的文件一次。

If the files are actually duplicates in your source folders then they will be added twice. This is intended (and desired) behaviour of InnoSetup. You can have multiple files with the same source, but with different destinations.

Make sure each file that is shared between the 2 different installation types is added from the same source directory. InnoSetup should then add the same file only once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文