Add custom page/field to NSIS setup created with electron-builder

后端 未结 1 1691
日久生厌
日久生厌 2021-01-22 11:54

I have created an Electron app which is packaged into an NSIS installer with electron-builder.

Now I would like to add a custom text field to the installer, where the us

相关标签:
1条回答
  • 2021-01-22 12:04

    I've been working on the same thing recently. Here's what I did:

    First, use the include option to point to a .nsh file (I'm doing this in package.json):

    {
      "build": {
        "appId": "...",
        "nsis": {
          "include": "build/installer.nsh"
        }
      }
    }
    

    Then you can put your custom NSIS code inside that .nsh file:

    !include nsDialogs.nsh
    
    XPStyle on
    
    Var Dialog
    
    Page custom myCustomPage
    
    Function myCustomPage
    
        nsDialogs::Create 1018
        Pop $Dialog
    
        ${If} $Dialog == error
            Abort
        ${EndIf}
    
        ...
    
        nsDialogs::Show
    
    FunctionEnd
    
    Section
    SectionEnd
    

    I adapted code from Mevia's question when I was creating my custom page. This will make a page that appears before the actual installation (Mevia's problem), so you should be careful where you save the input data.

    I believe that using include instead of a script is what allows you to write code for a single page, rather than having to write the entire installer script yourself.

    0 讨论(0)
提交回复
热议问题