繁体   English   中英

如何使用某些文件创建 setup.exe?

[英]How I can create setup.exe with some files?

我开发了 c# windows 窗体项目,我需要部署。
首先,我使用 setup factory 作为我的解决方案。
但是,我无法更新出现控制面板的图标。

其次,我在 Visual Studio 中使用了安装向导项目。 但是,我无法更新setup.exe图标。

那么,如何创建具有完全自定义功能的setup.exe

使用Nullsoft Scriptable Install System ,创建test.nsi文件并粘贴到脚本下方,然后使用 NSIS Compiler 打开该文件,然后Compile生成您想要的 setup.exe

测试文件

BrandingText " "
!define setup "./main_setup.exe"
 
; change this to wherever the files to be packaged reside
!define srcdir "."
 
!define company "Company Name"
 
!define prodname "Program Name"
!define exec "main.exe"
 
# optional stuff
 
; Set the text which prompts the user to enter the installation directory
 DirText "Test"
 
; text file to open in notepad after installation
!define notefile "license.txt"
 
; license text file
 !define licensefile license.txt
 
; icons must be Microsoft .ICO files
 !define icon "edf.ico"
 
; installer background screen
#!define screenimage splash.png
 
; file containing list of file-installation commands

 
; file containing list of file-uninstall commands
; !define unfiles "unfiles.nsi"
 
; registry stuff
 
!define regkey "Software\${company}\${prodname}"
!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${prodname}"
 
!define startmenu "$SMPROGRAMS\${company}\${prodname}"
!define uninstaller "uninstall.exe"
 
;--------------------------------
 
XPStyle on
ShowInstDetails hide
ShowUninstDetails hide
 
Name "${prodname}"
Caption "${prodname}"
 
!ifdef icon
Icon "${icon}"
!endif
 
OutFile "${setup}"
 
SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
 
InstallDir "$PROGRAMFILES\${company}\${prodname}"
InstallDirRegKey HKLM "${regkey}" ""
 
;!ifdef licensefile
;LicenseText "License"
;LicenseData "${srcdir}\${licensefile}"
;!endif
 
; pages
; we keep it simple - leave out selectable installation types
 
;!ifdef licensefile
;Page license
;!endif
 
; Page components
Page directory
Page instfiles
 
UninstPage uninstConfirm
UninstPage instfiles
 
;--------------------------------
 
AutoCloseWindow false
ShowInstDetails show
 
 
!ifdef screenimage
 
; set up background image
; uses BgImage plugin
 
Function .onGUIInit
    ; extract background BMP into temp plugin directory
    InitPluginsDir
    File /oname=$PLUGINSDIR\1.bmp "${screenimage}"
 
    BgImage::SetBg /NOUNLOAD /FILLSCREEN $PLUGINSDIR\1.bmp
    BgImage::Redraw /NOUNLOAD
FunctionEnd
 
Function .onGUIEnd
    ; Destroy must not have /NOUNLOAD so NSIS will be able to unload and delete BgImage before it exits
    BgImage::Destroy
FunctionEnd
 
!endif
 
; beginning (invisible) section
Section
 
  WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"
  ; write uninstall strings
  WriteRegStr HKLM "${uninstkey}" "DisplayName" "${prodname} (remove only)"
  WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"'
 
!ifdef filetype
  WriteRegStr HKCR "${filetype}" "" "${prodname}"
!endif
 
  WriteRegStr HKCR "${prodname}\Shell\open\command\" "" '"$INSTDIR\${exec} "%1"'
 
!ifdef icon
  WriteRegStr HKCR "${prodname}\DefaultIcon" "" "$INSTDIR\${icon}"
!endif
 
  SetOutPath $INSTDIR
 
 
; package all files, recursively, preserving attributes
; assume files are in the correct places
File /r "${srcdir}\*"
File /a "${srcdir}\${exec}"

 
;!ifdef icon
;File /a "${srcdir}\${icon}"
;!endif

 
  WriteUninstaller "${uninstaller}"
 
SectionEnd
 
; create shortcuts
Section
 
  CreateDirectory "${startmenu}"
  SetOutPath $INSTDIR ; for working directory
!ifdef icon
  CreateShortCut "${startmenu}\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}"
!else
  CreateShortCut "${startmenu}\${prodname}.lnk" "$INSTDIR\${exec}"
!endif
 
SectionEnd
 
; Uninstaller
; All section names prefixed by "Un" will be in the uninstaller
 
UninstallText "This will uninstall ${prodname}."
 
!ifdef icon
UninstallIcon "${icon}"
!endif
 
Section "Uninstall"
 
  DeleteRegKey HKLM "${uninstkey}"
  DeleteRegKey HKLM "${regkey}"
 
  Delete "${startmenu}\*.*"
  Delete "${startmenu}"

  RMDir /r "$INSTDIR"
 
SectionEnd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM