0
votes

I'm trying create custom page of uninstaller with feedback form. I read documentation (https://www.electron.build/configuration/nsis#NsisOptions-script) and made all stuff with macros customUnInstall. I found some issues with same problem, but it unresolved (https://github.com/electron-userland/electron-builder/issues/3871). The problem is using functions.

An error is returned when attempting to build: "warning 6020: Uninstaller script code found but WriteUninstaller never used - no uninstaller will be created. Error: warning treated as error"

There is the code of script, that I insert in customUnInstall script with !insertmacro:

Function un.TestFunc
    MessageBox MB_OK "HELLO"
FunctionEnd
!macro testmacro
        Var /GLOBAL Dialog
        Var /GLOBAL CheckBox

    nsDialogs::Create 1018
    Pop $Dialog

    ${NSD_CreateCheckbox} 0 25u 100% 10u "&Checkbox 1"
    Pop $CheckBox
    ${NSD_OnClick} $CheckBox un.TestFunc

        nsDialogs::Show
!macroend

For more information, there is some stuff about creating custom installer with electron-builder utilites https://www.electron.build/configuration/nsis#NsisOptions-script

So, what i'm doing wrong? I would be very grateful if you could help me.

UPD: Question #2. I found answer about custom installer page (Add custom page/field to NSIS setup created with electron-builder), but if I do same with uninstall section, same error appears. Of cource, in package.json I include uninstall.nsh instead installer.nsh.

!include nsDialogs.nsh

XPStyle on

Var Dialog
Var Text

UninstPage custom un.myCustomPage

Function un.myCustomPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}


    ${NSD_CreateLabel} 0 15 100% 20u "We are looking forward your return!"
    Pop $Text

    nsDialogs::Show

FunctionEnd



Section
SectionEnd
2

2 Answers

0
votes

Simply add WriteUninstaller [Path]exename.exe into your uninstall section.

See details here: https://nsis.sourceforge.io/Docs/Chapter4.html

Optionally: you can turn off /WX treats warnings as errors (remove /WX from the command line passed to makensis.exe)

See details here: https://nsis.sourceforge.io/Docs/Chapter3.html#usagereference

0
votes

add nsis Option warningsAsErrors: false , can get rid of this error :warning 6020: Uninstaller script code found but WriteUninstaller never used - no uninstaller will be , my code : nsis configuration

nsis: {
     warningsAsErrors: false,
     include: 'build/nsis/uninstaller.nsh',
}

uninstaller.nsh

!include nsDialogs.nsh

XPStyle on
Var /GLOBAL Dialog_1
Var /GLOBAL VLine
Var /GLOBAL Label_1
Var /GLOBAL CheckBox_1
Var /GLOBAL Checkbox_State

# Create a custom uninstall page
UninstPage custom un.nsDialogsPage un.nsDialogsPageLeave  
Function un.nsDialogsPage
    nsDialogs::Create 1018
    Pop $Dialog_1
    ${If} $Dialog_1 == error
        Abort
    ${EndIf}
    ${NSD_CreateVLine} 0 30u 100% 12u ""
    Pop $VLine
    ${NSD_CreateLabel} 0 10u 100% 12u "Uninstallation prompt: Do you want to delete user data locally?"
    Pop $Label_1
    ${NSD_CreateCheckbox} 0 50u 100% 10u "&Confirm to delete local user data"
    Pop $CheckBox_1
    nsDialogs::Show
FunctionEnd
Function un.nsDialogsPageLeave
${NSD_GetState} $CheckBox_1 $Checkbox_State
FunctionEnd

Section
SectionEnd


!macro customUnInstall
; Uninstall process execution
    ${ifNot} ${isUpdated}
        ${If} $Checkbox_State == ${BST_CHECKED}
          # If you tick Delete fixed folder
          MessageBox MB_OKCANCEL "Are you sure to delete user data?" IDOK label_ok  IDCANCEL  label_cancel
          label_ok:
              # Delete user data folder
              RMDir /r $PROFILE\xxx
              Goto end
          label_cancel:
              Goto end
          end:
        ${EndIf}
    ${endIf}
!macroend

I'm prompting the user to delete the folder. More configuration: https://nsis.sourceforge.io/Docs/nsDialogs/Readme.html