我正在更新现有应用程序,并希望设置新的应用程序版本号。我使用了!define VERSION"版本号"但该应用程序仍保留以前的版本号。我也经历了NSIS SourceForge寻找解决方案,但没有一个可以显示然后更改版本号。我要显示的版本号是 2.1.1259.1 ,但它会一直返回旧的 2.0.236.1258
代码如下:
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Application Name"
!define PRODUCT_VERSION "2.1.1259.1"
!define VERSION "2.1.1259.1"
!define PRODUCT_PUBLISHER "CompanyName"
!define PRODUCT_WEB_SITE "http://www.CompanyName.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
Var InDebugMode
Var SQLAccountType
Var SQLUSER
Var SQLPASSWORD
Var SQLSERVER
Var RunInstalls
Var CurrentStep
Var InstallDB
Var SupportedVersions
Var SetupFileName
Var InstallsPath
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "LogicLib.nsh"
!include "Source\Scripts\DotNetDetect.nsh"
!include "Source\Scripts\WriteToFile.nsh"
!include "Source\Scripts\Page_InstallerPage.nsh"
!include "Source\Scripts\TrimString.nsh"
!include WinMessages.nsh
!include "LogicLib.nsh"
!include "x64.nsh"
!include "Source\Scripts\StrRep.nsh"
!include "Source\Scripts\InstallerControl.nsh"
!include "Source\Scripts\ReplaceInFile.nsh"
!include "Source\Scripts\Debug.nsh"
!include "Source\Scripts\VersionCompare.nsh"
!include "Source\Scripts\CheckWindows.nsh"
!include "Source\Scripts\CheckDotNet4.nsh"
!include "Source\Scripts\CreateShortcuts.nsh"
!include "Source\Scripts\InstallFonts.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define UMUI_HEADERIMAGE_BMP "ilaundry-logo.bmp"
!define MUI_BGCOLOR 0xFFFFFF
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipOnRestart_Licence
!insertmacro MUI_PAGE_LICENSE "Source\Scripts\TAC.TXT"
Page custom Installer_Page_Start Installer_Page_Leave
!include "Source\Scripts\InstallCrystalReports.nsh"
!include "Source\Scripts\UpdateConfigFile.nsh"
!include "Source\Scripts\InstallSqlServer.nsh"
!include "Source\Scripts\InstallDatabase.nsh"
!include "Source\Scripts\InstallDigitalPersona.nsh"
!include "Source\Scripts\InstallAccessDBEngine.nsh"
!include "Source\Scripts\InstallApplication.nsh"
!include "Source\Scripts\InstallBackup.nsh"
!include "Source\Scripts\UninstallSqlServer.nsh"
!include "Source\Scripts\SplashController.nsh"
!define MUI_PAGE_CUSTOMFUNCTION_PRE Skip_Finish
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
InstallDir "$PROGRAMFILES\ApplicationName"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function SkipOnRestart_Licence
${IfNot} $CurrentStep == "new"
Abort
${EndIf}
FunctionEnd
Function Skip_Finish
Abort
FunctionEnd
Function SharedOnInt
InitPluginsDir
File /oname=$PLUGINSDIR\InstallScreen.ini "Source\Scripts\InstallScreen.ini"
StrCpy $InDebugMode 'True'
StrCpy $RunInstalls 'True'
strcpy $StepBeforeReboot "none"
CALL LoadCurrentStep
PUSH 'onInt - Start'
PUSH ''
CALL DumpValues
SetRegView 64
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
SetRegView 32
#call uninstallSQLServer
writeUninstaller $INSTDIR\uninstaller.exe
PUSH 'onInt - End'
PUSH ''
CALL DumpValues
FunctionEnd
Function .onGUIEnd
;Push '$INSTDIR\LogDump.txt'
;Call DumpLog
FunctionEnd
Var UnRegValue
# create a section to define what the uninstaller does.
# the section will always be named "Uninstall"
section "Uninstall"
# Always delete uninstaller first
delete $INSTDIR\uninstaller.exe
ReadRegStr $UnRegValue HKLM "SOFTWARE\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\${PRODUCT_VERSION}" "InstalledSQL"
${If} $UnRegValue == "true"
call un.uninstallSQLServer
${EndIf}
ReadRegStr $UnRegValue HKLM "SOFTWARE\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\${PRODUCT_VERSION}" "InstalledCrystalReports"
${If} $UnRegValue == "true"
call un.uninstallSQLServer
${EndIf}
;StrCmp $UnRegValue "true" UninstallSQLServer
sectionEnd
我意识到有很多!包括但是为了节省问题空间我暂时把它们排除在外但是如果你认为问题可能隐藏在其中一个中我会添加那个特定的.nsh文件。最后,我们将不胜感激。
答案 0 :(得分:1)
PRODUCT_VERSION只是一个对编译器没有特殊意义的定义,VI *属性用于设置NSIS中的版本信息。
版本信息存储在binary block和readable strings中。二进制块信息由VIProductVersion
和VIFileVersion
属性控制,字符串信息由VIAddVersionKey
设置。这些属性甚至不存在于您发布的代码中,因此它们必须位于其中一个.nsh文件中?也许你在不止一个地方设置它们?
看起来应该是这样的:
!define PRODUCT_VERSION "2.1.1259.1"
!define VERSION "2.1.1259.1"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "LegalCopyright" "(C) Blah blah Inc."
VIAddVersionKey "FileDescription" "Blah blah blergh fancy app"
如果在验证您没有在多个位置设置信息后仍然得到错误的值,那么可能Explorer正在缓存信息。您可以使用Resource Hacker ...
等工具检查原始版本信息