• NSIS脚本 打包安装程序


    相关工具

    nsis

    http://nsis.sourceforge.net/Special_Builds

    HM NIS Edit

    http://hmne.sourceforge.net/

    例子:

    ; Script generated by the HM NIS Edit Script Wizard.
    
    ; !include "DotNetChecker.nsh"
    
    ; HM NIS Edit Wizard helper defines
    
    !define PRODUCT_NAME "产品名称"
    
    !define PRODUCT_VERSION "1.0版本"
    
    !define PRODUCT_PUBLISHER "公司 company, Inc."
    
    !define PRODUCT_DIR_REGKEY "SoftwareMicrosoftWindowsCurrentVersionApp PathsAt.WPF.exe"
    
    !define PRODUCT_UNINST_KEY "SoftwareMicrosoftWindowsCurrentVersionUninstall${PRODUCT_NAME}"
    
    !define PRODUCT_UNINST_ROOT_KEY "HKLM"
    
    ; MUI 1.67 compatible ------
    
    !include "MUI.nsh"
    
    ; MUI Settings
    
    !define MUI_ABORTWARNING
    
    !define MUI_ICON "logo_JH.ico" ;安装程序图标
    
    ;!define MUI_ICON "${NSISDIR}ContribGraphicsIconsmodern-install.ico"
    
    !define MUI_UNICON "${NSISDIR}ContribGraphicsIconsmodern-uninstall.ico"
    
    ; Language Selection Dialog Settings
    
    !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
    
    !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
    
    !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
    
    ; Welcome page
    
    !insertmacro MUI_PAGE_WELCOME
    
    ; License page
    
    ;!define MUI_LICENSEPAGE_RADIOBUTTONS
    
    ;!insertmacro MUI_PAGE_LICENSE "c:path	olicenceYourSoftwareLicence.txt"
    
    ; Directory page
    
    !insertmacro MUI_PAGE_DIRECTORY
    
    ; Instfiles page
    
    !insertmacro MUI_PAGE_INSTFILES
    
    ; Finish page
    
    !define MUI_FINISHPAGE_RUN "$INSTDIRAt.WPF.exe"
    
    !insertmacro MUI_PAGE_FINISH
    
    ; Uninstaller pages
    
    !insertmacro MUI_UNPAGE_INSTFILES
    
    ; Language files
    
    !insertmacro MUI_LANGUAGE "English"
    
    !insertmacro MUI_LANGUAGE "SimpChinese"
    
    ; MUI end ------
    
    Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
    
    OutFile "ArsenalTherSetup.exe"
    
    InstallDir "$PROGRAMFILESArsenalThe"
    
    InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
    
    ShowInstDetails show
    
    ShowUnInstDetails show
    
    Function .onInit
    
      !insertmacro MUI_LANGDLL_DISPLAY
    
    FunctionEnd
    
    Function GetNetFrameworkVersion
    
    ;获取.Net Framework版本支持
    
    Push $1
    
    Push $0
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv4Full" "Install"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv4Full" "Version"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.5" "Install"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.5" "Version"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.0Setup" "InstallSuccess"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.0Setup" "Version"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv2.0.50727" "Install"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv2.0.50727" "Version"
    
    StrCmp $1 "" +1 +2
    
    StrCpy $1 "2.0.50727.832"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv1.1.4322" "Install"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv1.1.4322" "Version"
    
    StrCmp $1 "" +1 +2
    
    StrCpy $1 "1.1.4322.573"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    ReadRegDWORD $0 HKLM "SOFTWAREMicrosoft.NETFrameworkpolicyv1.0" "Install"
    
    ReadRegDWORD $1 HKLM "SOFTWAREMicrosoft.NETFrameworkpolicyv1.0" "Version"
    
    StrCmp $1 "" +1 +2
    
    StrCpy $1 "1.0.3705.0"
    
    StrCmp $0 1 KnowNetFrameworkVersion +1
    
    StrCpy $1 "not .NetFramework"
    
    KnowNetFrameworkVersion:
    
    Pop $0
    
    Exch $1
    
    FunctionEnd
    
    ;安装.Net Framework版本
    Section -.NET
    
    Call GetNetFrameworkVersion
    
    Pop $R1
    
     ${If} $R1 < '4.5'
    
     SetDetailsPrint textonly
    
     DetailPrint "正在在安装 .NET Framework 4.5"
    
     SetDetailsPrint listonly
    
     SetOutPath "$TEMP"
    
     SetOverwrite on
    
     File "F:SoftToolsdotnetfx45_full_x86_x64.exe"
    
     ExecWait '$TEMPdotnetfx45_full_x86_x64.exe /q /norestart /ChainingPackage FullX64Bootstrapper' $R1
    
     Delete "$TEMPdotnetfx45_full_x86_x64.exe"
    
     ${EndIf}
    
    SectionEnd
    
    Section "MainSection" SEC01
    
      SetOutPath "$INSTDIR"
    
      ;!insertmacro CheckNetFramework 47
    
      ;!insertmacro CheckNetFramework 45
    
      SetOverwrite ifnewer
      ;wpf 目录下所有的文件和文件夹 加入
      File /r "WPF*"
    
    SectionEnd
    
    Section -AdditionalIcons
    
      CreateShortCut "$SMPROGRAMS系统名称Uninstall.lnk" "$INSTDIRuninst.exe"
    
    SectionEnd
    
    Section -Post
    
      WriteUninstaller "$INSTDIRuninst.exe"
    
      WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIRArsenalThermostat.WPF.exe"
    
      WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
    
      WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIRuninst.exe"
    
      WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIRArsenalThermostat.WPF.exe"
    
      WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
    
      WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
    
    SectionEnd
    
    Function un.onUninstSuccess
    
      HideWindow
    
      MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"
    
    FunctionEnd
    
    Function un.onInit
    
    !insertmacro MUI_UNGETLANGUAGE
    
      MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ,其及所有的组件?" IDYES +2
    
      Abort
    
    FunctionEnd
    
    Section Uninstall
    ;删除 安装目录下的所有文件
      Delete "$INSTDIR*"
    
      RMDir "$SMPROGRAMS系统名称"
    
      RMDir "$INSTDIR"
    
      DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
    
      DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
    
      SetAutoClose true
    
    SectionEnd
    
    

    安装包 添加注册 dll

    Section "MainSection" SEC01
        ;;注册。注意:不加/s会弹出注册成功的弹出框。
    ;ExecWait 'regsvr32 /s "$INSTDIR	est.dl"'
    ExecWait 'regsvr32  "$INSTDIRzksdkzkemkeeper.dll"'
    ;反注册
    ;ExecWait 'regsvr32 /s /u "$INSTDIR	est.dl"'
    SectionEnd
    

    NSIS插件 检测 .netFramwork

    https://github.com/ReVolly/NsisDotNetChecker

    nsis 安装包 检测 安装 .net Framwork 插件 使用说明地址 https://github.com/ReVolly/NsisDotNetChecker

  • 相关阅读:
    【多视图几何】TUM 课程 第5章 双视图重建:线性方法
    【多视图几何】TUM 课程 第4章 同名点匹配
    【多视图几何】TUM 课程 第3章 透视投影
    SpringMVC配置实例
    sqlserver的触发器练习实例
    zTree学习实例
    浅谈JVM与内存分配
    Ajax的简单实用实例
    Sqlserver事务备份和还原实例
    JQueryEasyUI学习简单Demo
  • 原文地址:https://www.cnblogs.com/z_lb/p/9145006.html
Copyright © 2020-2023  润新知