【问题标题】:How I can create setup.exe with some files?如何使用一些文件创建 setup.exe?
【发布时间】:2019-05-07 15:49:32
【问题描述】:

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

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

那么,我如何创建完全自定义的setup.exe

【问题讨论】:

  • 我检查了那个方法,也有效,但我不能使用我的图标,因为颜色更新为低位
  • 我认为,setup wizad 不是我的项目的好解决方案,是否有其他解决方案可以完全自定义创建 setup.exe?
  • 如果您需要安装程序,您可以尝试例如inno-setup
  • 我完全同意 vik_78。 Inno Setup 是一种流行、功能丰富、易于学习的安装程序,与许多其他安装程序相比,它的简单设置更加直接。

标签: c# visual-studio-2015 icons exe setup-project


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多