简体   繁体   English

更改我的NSIS安装程序应用程序版本

[英]Changing my NSIS installer Application Version

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. 我使用了!define VERSION“版本号”,但应用程序仍保留先前的版本号。 I have also been going through NSIS SourceForge in search of the solution but none that could show and then change the Version Number. 我也一直在通过NSIS SourceForge来寻找解决方案,但是没有一个可以显示然后更改版本号。 The Version Number i want to show is 2.1.1259.1 but it keeps returning the old 2.0.236.1258 我要显示的版本号是2.1.1259.1,但它一直返回旧的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. 我意识到有很多!include,但是为了节省问题空间,我暂时将它们省略了,但是如果您认为问题可能隐藏在其中一个中,我将添加该特定的.nsh文件。 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. PRODUCT_VERSION只是对编译器没有特殊意义的定义,VI *属性用于设置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 . 二进制块信息由VIProductVersionVIFileVersion属性控制,字符串信息由VIAddVersionKey设置。 These attributes are not even present in the code you posted so they must be in one of the .nsh files? 这些属性甚至都没有出现在您发布的代码中,因此它们必须位于.nsh文件之一中吗? 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. 如果在确认没有在多个位置设置信息后仍然得到错误的值,则说明Explorer可能正在缓存信息。 You can inspect the raw version information with a tool like Resource Hacker ... 您可以使用Resource Hacker之类的工具检查原始版本信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM