I am updating an existing application and want to set the new Application Version Number. I used the !define VERSION "Version Number" but the application still retains the previous Version number. I have also been going through NSIS SourceForge in search of the solution but none that could show and then change the Version Number. The Version Number i want to show is 2.1.1259.1 but it keeps returning the old 2.0.236.1258
The code looks as follows:
; 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
I realize there are a lot of !include but to save question space I left them out for now but if you think the problem may be hidden in one of them I will add that specific .nsh file. Any help would be appreciated in the end.
PRODUCT_VERSION is just a define with no special meaning to the compiler, the VI* attributes are used to set the version information in NSIS.
The version information is stored both in a binary block and as readable strings. The binary block information is controlled by the VIProductVersion
and VIFileVersion
attributes and the string information is set with VIAddVersionKey
. These attributes are not even present in the code you posted so they must be in one of the .nsh files? Perhaps you are setting them in more than one place?
It should look something like this:
!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"
If you are still getting the wrong values after verifying that you are not setting the information in multiple places then perhaps Explorer is caching the information. You can inspect the raw version information with a tool like Resource Hacker...