Search code examples
inno-setuppascalscript

How to use signonce with just one file with this ISPP macro?


I am not sure I have done this right:

; 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")

The new bit of code is here:

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

I did not know if I needed the parseoption calls?

Also, I have an issue in that this file:

MSAToolsGMailClassLibrary.dll

Also needs the signonce flag. But all the other dll files in the MSAToolsGMailClassLibrary folder don't.

How can we do this?


Solution

  • Modify the FileEntry macro accordingly:

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

    (untested)