i开发了C#Windows表单项目,我需要部署。
首先,我将设置工厂用于解决方案。
但是,我无法更新出现控制面板的图标。
第二,我在Visual Studio中使用了设置向导项目。但是,我无法更新setup.exe
图标。
那么,如何使用Full自定义创建setup.exe
?
with nullsoft脚本安装系统,创建test.nsi
文件并在脚本下面粘贴,然后使用NSIS编译器打开文件,以及Compile
,生成您想要的
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 "SoftwareMicrosoftWindowsCurrentVersionUninstall${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=$PLUGINSDIR1.bmp "${screenimage}"
BgImage::SetBg /NOUNLOAD /FILLSCREEN $PLUGINSDIR1.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}Shellopencommand" "" '"$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