我开发了c#Windows窗体项目,需要部署。
首先,我使用setup factory作为解决方案。
但是,我无法更新出现在控制面板中的图标。
第二,我在Visual Studio中使用了安装向导项目。
但是,我无法更新setup.exe
图标。
那么,如何完全自定义创建setup.exe
?
答案 0 :(得分:-1)
使用Nullsoft Scriptable Install System,
创建 test.nsi
文件并粘贴到脚本下方,然后使用 NSIS 编译器打开该文件,然后Compile
生成您想要的 setup.exe
test.nsi
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