inno setup :设置初始阶段需要 6 分钟?

Mel*_*bit 7 inno-setup

我使用 Inno Setup 来制作游戏安装程序,但我发现了一些问题。

当我运行“Setup_1.0.121.exe”时,大约需要 6 分钟才会出现第一个屏幕。我的设置总大小是 4.76GB,这是文件列表

  • Setup_1.0.121.exe:623,863 字节
  • Setup_1.0.121-1a.bin:1,707,575,872 字节
  • setup_1.0.121-1b.bin:1,708,200,000 字节
  • Setup_1.0.121-1c.bin:1,697,243,193 字节

我尝试深入了解初始过程发生了什么,并procexp发现了这个

  • Setup_1.0.121.tmp:I/O 读取字节 5,085,307,002:I/O 写入字节 1,061,076

我的Setup_1.0.121.exe 在初始阶段读取每个字节。这就是为什么需要这么长时间。

我的怀疑是插件“Isskin”,我只是添加用于装饰。

function InitializeSetup(): Boolean;
    begin
      ExtractTemporaryFile('Office2007.cjstyles');
      LoadSkin(ExpandConstant('{tmp}\Office2007.cjstyles'), '');
      Result := True;
    end; 
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

TLa*_*ama 4

如果您正在使用(我假设您这样做),并且您在该部分中的那些大文件之后SolidCompression列出了任何临时文件(ISSkin.dll和/或) ,那么初始化需要很长时间,因为安装程序正在提取之前列出的所有文件那些临时文件。Office2007.cjstyles[Files]

这可能是由ISSkin.dll脚本引擎提取加载的库(如果您没有使用delayload标志)引起的,或者是由函数手动提取Office2007.cjstyles皮肤文件引起的ExtractTemporaryFile。该函数的参考中甚至有警告:

启用固体压缩后,请务必在 [文件] 部分的顶部(或附近)列出临时文件。为了在固体压缩安装中提取任意文件,安装程序必须首先解压缩所有先前的文件(到内存中的临时缓冲区)。如果 [Files] 部分中指定文件上方列出了许多其他文件,这可能会导致严重的延迟。

如果我的假设是正确的,并且您已启用SolidCompression这些巨大数据文件下面列出的临时文件,那么我们可以将您的脚本重建为如下所示:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
SolidCompression=yes

[Files]
; first are listed huge files
Source: "Setup_1.0.121.exe"; DestDir: "{app}"
Source: "Setup_1.0.121-1a.bin"; DestDir: "{app}"
Source: "Setup_1.0.121-1b.bin"; DestDir: "{app}"
Source: "Setup_1.0.121-1c.bin"; DestDir: "{app}"
; if SolidCompression is enabled, all the prior files are extracted
; when any of the the following files is extracted
Source: "ISSkin.dll"; DestDir: "{tmp}"; Flags: dontcopy
Source: "Office2007.cjstyles"; DestDir: "{tmp}"; Flags: dontcopy
...
Run Code Online (Sandbox Code Playgroud)

如果您仔细阅读这篇文章,您已经知道答案就在参考文献的引用中。您需要做的就是在该[Files]部分的顶部列出所有临时文件,以避免解压巨大的文件。所以上面的脚本将变成:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
SolidCompression=yes

[Files]
; first are listed temporary files
Source: "ISSkin.dll"; DestDir: "{tmp}"; Flags: dontcopy
Source: "Office2007.cjstyles"; DestDir: "{tmp}"; Flags: dontcopy
; the huge files are now extracted just when they are needed
Source: "Setup_1.0.121.exe"; DestDir: "{app}"
Source: "Setup_1.0.121-1a.bin"; DestDir: "{app}"
Source: "Setup_1.0.121-1b.bin"; DestDir: "{app}"
Source: "Setup_1.0.121-1c.bin"; DestDir: "{app}"
...
Run Code Online (Sandbox Code Playgroud)