NSIS - put EXE version into name of installer

前端 未结 7 718
臣服心动
臣服心动 2020-12-24 03:04

NSIS has a Name variable that you define in the script:

Name \"MyApp\"

It defines the name of the installer, that gets displayed as the win

相关标签:
7条回答
  • 2020-12-24 04:05

    You can do this without .NET by using the GetVersion plugin, but following the same basic logic:

    Here is ExtractVersionInfo.nsi:

    !define File "...\path\to\your\app.exe"
    
    OutFile "ExtractVersionInfo.exe"
    SilentInstall silent
    RequestExecutionLevel user
    
    Section
    
     ## Get file version
     GetDllVersion "${File}" $R0 $R1
      IntOp $R2 $R0 / 0x00010000
      IntOp $R3 $R0 & 0x0000FFFF
      IntOp $R4 $R1 / 0x00010000
      IntOp $R5 $R1 & 0x0000FFFF
      StrCpy $R1 "$R2.$R3.$R4.$R5"
    
     ## Write it to a !define for use in main script
     FileOpen $R0 "$EXEDIR\App-Version.txt" w
      FileWrite $R0 '!define Version "$R1"'
     FileClose $R0
    
    SectionEnd
    

    You compile this once, and then call it from your real installer:

    ; We want to stamp the version of the installer into its exe name.
    ; We will get the version number from the app itself.
    !system "ExtractVersionInfo.exe"
    !include "App-Version.txt"
    Name "My App, Version ${Version}"
    OutFile "MyApp-${Version}.exe"
    
    0 讨论(0)
提交回复
热议问题