I am attempting to remove one more step in my application's release process by automatically retrieving versioning info from my executable (in this case, a .NET application).
Up to this point, I have been able to get by with a limited knowledge of NSIS, but I am quickly learning that this is not enough.
Step 1: Declare version info in executable
In AssemblyInfo.cs, I declare [assembly: AssemblyVersion("1.0.0.1")]
. This successfully makes the version info appear in the compiled executable (under "File version" and "Product version").
Step 2: Retrieve version info from executable
According to this article on "GetFileVersion", importing "FileFunc.nsh" allows you to retrieve version info from an executable.
Code used:
Section
Var /GLOBAL version
${GetFileVersion} "C:\test.exe" $version
...
SectionEnd
Step 3: Verify contents of function call
Based on section 5.1.7 of the documentation, I should be able to print to the command line during compile time using the "!echo" command. The difference between printing the contents of a variable (or a constant, etc) still confuses me, so I have tried all four of these options:
!echo $version
!echo "$version"
!echo "${version}"
!echo ${version}
This results in:
$version (InstallScript.nsi:15)
$version (InstallScript.nsi:16)
${version} (InstallScript.nsi:17)
${version} (InstallScript.nsi:18)
Step 4: Declare the installer metadata
Based on section 4.8.3, I should be able to add installer metadata via VIProductVersion
and VIAddVersionKey
.
VIProductVersion $version
VIAddVersionKey "FileVersion" "$version"
In the built installer, this adds the string "$version" into the specified fields.
Is there a ToString()
equivalent in NSIS? How can I access a variable's contents? Does the print of the variable name mean that it has no contents? How can I verify that GetFileVersion
is called correctly, executes correctly, and returns a value?