Difference between revisions of "Creating installers for Verge3D plugins"

From Verge3D Wiki
Jump to navigationJump to search
m
m
 
Line 1: Line 1:
[[Category:Plugins]]
[[Category:Plugins]]
[[Category:Tutorials]]
[[Category:Tutorials]]
By using NSIS (Nullsoft Scriptable Install System) you can wrap your plugins to user-friendly installers. Contrary to manual ZIP distribution, installers search for Verge3D distros and automatically copy plugin files to the required plugin folders. Also, installers display licensing info, help URLs, and create necessary script to uninstall your products.
By using NSIS (Nullsoft Scriptable Install System) you can wrap your plugins to user-friendly installers. Contrary to manual ZIP distribution, installers search for Verge3D distros and automatically copy plugin files to the required plugin folders. Also, installers display licensing info, help URLs, and create necessary scripts to uninstall your products.


  NSIS supports Windows-only installers. For macOS and Linux, ZIP is still the preferred way to distribute your plugins.
  NSIS supports Windows-only installers. For macOS and Linux, ZIP is still the preferred way to distribute your plugins.

Latest revision as of 12:04, 17 August 2022

By using NSIS (Nullsoft Scriptable Install System) you can wrap your plugins to user-friendly installers. Contrary to manual ZIP distribution, installers search for Verge3D distros and automatically copy plugin files to the required plugin folders. Also, installers display licensing info, help URLs, and create necessary scripts to uninstall your products.

NSIS supports Windows-only installers. For macOS and Linux, ZIP is still the preferred way to distribute your plugins.

To use NSIS, first download and install it.

Then create setup.nsi script in the plugin folder with the following content:

!define APPNAME "Example Plugin"
!define COMPANYNAME "YourCompany"
!define DESCRIPTION "Example Plugin Setup Wizard"
!define HELPURL "https://www.example.com/"
!define UPDATEURL "https://www.example.com/"
!define ABOUTURL "https://www.example.com/"

Unicode true

SetCompress off
SetCompressor /SOLID lzma

!include "MUI2.nsh"
 
InstallDir "$PROGRAMFILES64\ExamplePlugin"

# Installer/uninstaller's title bar
Name "${COMPANYNAME} ${APPNAME}"
OutFile "..\example-plugin.exe"

RequestExecutionLevel highest
 
!include LogicLib.nsh
 
# interface Settings

!define MUI_ABORTWARNING

!define MUI_WELCOMEPAGE_TITLE "Example Plugin installation"
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEPAGE_TEXT "This Setup Wizard will install Example Plugin on your computer."

!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Finish Text"

!define MUI_FINISHPAGE_TITLE "Installation is complete"
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_TEXT "Thank you for choosing Example Plugin. Get started with the Startup Guide (click on the link below)."
!define MUI_FINISHPAGE_LINK "Open Startup Guide"
!define MUI_FINISHPAGE_LINK_LOCATION ${HELPURL}
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_NOAUTOCLOSE

# pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

Section
    SectionIn RO

    # use installation folder only for license and uninstaller
    SetOutPath "$INSTDIR"
    File LICENSE.txt

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Blender" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for Blender is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for 3ds Max" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for 3ds Max is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Maya" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for Maya is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D Ultimate" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D Ultimate is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    WriteRegStr HKCU "Software\YourCompany\Example Plugin" "Install_Dir" "$INSTDIR"

    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "DisplayName" "Example Plugin"
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "UninstallString" "$INSTDIR\Uninstall.exe"
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "NoModify" 1
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "NoRepair" 1
 
    WriteUninstaller "$INSTDIR\Uninstall.exe"

SectionEnd


Section "Uninstall"

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Blender" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for 3ds Max" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Maya" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D Ultimate" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    Delete "$INSTDIR\*.*"
    RMDir "$INSTDIR"

    DeleteRegKey HKCU "Software\YourCompany\Example Plugin"
    DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin"
 
SectionEnd

Modify the script by replacing "Example Plugin" with the actual plugin name and "ExamplePlugin" with the preferred plugin path. Also choose proper name for the EXE file "example-plugin.exe", specify company name instead of "YourCompany", edit URLs and text fields which will be displayed to the users.

You also need to place LICENSE.txt file to the plugin directory. This file will be displayed to the user before the actual installation starts.

Launch NSIS, click Compile NSI scripts, then select setup.nsi script:

Nsis windows.jpg

Done! Check out the EXE file generated along the plugin directory. Launch the installer to confirm it works correctly:

Nsis plugin installer.jpg