installationwindows-installernsiselectron-builder

how to add "Choose Components" page in NSIS (using macro with .nsh)


I'm using electron-builder.

Here I can customise nsis script with pre-defined macros. (https://www.electron.build/configuration/nsis#custom-nsis-script)

according to documents, the macros that I can use to customize are: customHeader, preInit, customInit, customUnInit, customInstall, customUnInstall, customRemoveFiles, customInstallMode.

I want to put a page where I can select what to install. (see below example) enter image description here

Which macros should I use to insert this page? And if possible, can I get some example script as well?

Thanks for your tips in advance.


Solution

  • I am not that familiar with the electron-builder, but I can show you how you might do something like this in real NSIS, which I guess should also work for you.

    First you will have to define the page like so:

    Page components SelectComponents
    

    Then you would have to define a function with the same name as the page. Here you could for example set the branding image which will be displayed on the Page:

    Function SelectComponents 
      SetBrandingImage path\image.bmp
    FunctionEnd
    

    Last you can add your sections. Here you can customize them however you want. See description from NSIS Manual (https://nsis.sourceforge.io/Docs/Chapter4.html#sections).

    Section /o "My section"
      ; Copy files and do other stuff
    SectionEnd
    

    Let me know if I could help you with your issue.