如何通过此ISPP宏仅对一个文件使用signonce?

时间:2019-06-13 17:36:20

标签: inno-setup pascalscript

我不确定我做对了吗

; We use the preprocessor to compare the DLL versions.
; This results in a smaller setup executable.
; See: https://stackoverflow.com/a/49647793/2287576
#pragma parseroption -p-

#define FileEntry(Source, DestPath) \
    "Source: \"" + Source + "\"; DestDir: \"" + DestPath + "\"; Flags: ignoreversion\n"

#define ProcessFile(RootPath, Path, AlternativePath, DestPath, FindResult, FindHandle) \
    FindResult ? \
        Local[0] = FindGetFileName(FindHandle), \
        Local[1] = AddBackslash(Path) + Local[0], \
        Local[2] = AddBackslash(AlternativePath) + Local[0], \
        Local[3] = AddBackslash(RootPath) + Local[1], \
        Local[4] = AddBackslash(RootPath) + Local[2], \
        Local[5] = \
           FileExists(Local[4]) && \
           (GetFileVersion (Local[3]) == GetFileVersion (Local[4])), \
        FileEntry((Local[5] ? Local[2] : Local[1]), DestPath) + \
        ProcessFile(RootPath, Path, AlternativePath, DestPath, \
            FindNext(FindHandle), FindHandle) \
    : ""

#define ProcessFolderWithAlternativeSource(RootPath, Path, AlternativePath, DestPath) \
    Local[0] = FindFirst(AddBackslash(AddBackslash(RootPath) + Path) + "*.dll", 0), \
    ProcessFile(RootPath, Path, AlternativePath, DestPath, Local[0], Local[0])

#pragma parseroption -p+

#emit ProcessFolderWithAlternativeSource( \
    SetupSetting("SourceDir"), "OutlookCalIFConsole", ".", "{app}\OutlookCalIFConsole")

Source: "OutlookCalIFConsole\OutlookCalIFConsole.exe"; DestDir: "{app}\OutlookCalIFConsole"; Flags: ignoreversion sign
Source: "OutlookCalIFConsole\OutlookCalIFConsole.exe.config"; DestDir: "{app}\OutlookCalIFConsole"; Flags: ignoreversion

; MSATools GMail Library
#emit ProcessFolderWithAlternativeSource( \
    SetupSetting("SourceDir"), "MSAToolsGMailClassLibrary", ".", "{app}\MSAToolsGMailClassLibrary")

新的代码在这里:

; MSATools GMail Library
#emit ProcessFolderWithAlternativeSource( \
    SetupSetting("SourceDir"), "MSAToolsGMailClassLibrary", ".", "{app}\MSAToolsGMailClassLibrary")

我不知道是否需要parseoption通话吗?

此外,该文件存在一个问题:

MSAToolsGMailClassLibrary.dll

还需要signonce标志。但是MSAToolsGMailClassLibrary文件夹中的所有其他dll文件都没有。

我们该怎么做?

1 个答案:

答案 0 :(得分:1)

相应地修改FileEntry宏:

#define FileEntry(Source, DestPath) \
  "Source: \"" + Source + "\"; DestDir: \"" + DestPath + "\"; Flags: ignoreversion " + \
  (SameText(ExtractFileName(Source), "MSAToolsGMailClassLibrary.dll") ? "signonce" : "") + \
  "\n"

(未经测试)