I'm trying to remove another step in the process of releasing the application, automatically getting version information from my executable file (in this case, a .NET application).
Up to this point, I have managed to gain limited knowledge of NSIS, but I quickly find out that this is not enough.
Step 1: declare version information in the executable
In AssemblyInfo.cs, I declare [assembly: AssemblyVersion("1.0.0.1")] . This successfully makes the version information displayed in the compiled executable (in the "File Version" and "Product Version" sections).
Step 2. Extract version information from the executable
According to this article, in the "GetFileVersion" article, importing "FileFunc.nsh" allows you to get version information from an executable file.
Used code:
Section Var /GLOBAL version ${GetFileVersion} "C:\test.exe" $version ... SectionEnd
Step 3. Checking the contents of the function call
Based on section 5.1.7 of the documentation , I should be able to print on the command line at compile time using "! Echo". The difference between printing the contents of a variable (or constant, etc.) still confuses me, so I tried all four of these options:
!echo $version !echo "$version" !echo "${version}" !echo ${version}
It leads to:
$version (InstallScript.nsi:15) $version (InstallScript.nsi:16) ${version} (InstallScript.nsi:17) ${version} (InstallScript.nsi:18)
Step 4: Declare Installer Metadata
Based on section 4.8.3 , I should be able to add installer metadata using VIProductVersion and VIAddVersionKey .
VIProductVersion $version VIAddVersionKey "FileVersion" "$version"
In the built-in installer, this adds the string "$ version" to the specified fields.
Is there an equivalent ToString() in NSIS? How can I access the contents of a variable? Does printing a variable name mean it has no content? How to check if GetFileVersion is called GetFileVersion , is executed correctly and returns a value?