I use maven, I have a maven-project with version XYZ-SNAPSHOT, and I use maven-nsis-plugin . Because the Version is in format XYZ-SNAPSHOT, I have to remove this suffix and repace it with a 0.
The maven plugin maven-nsis-plugin generates a project.nsh:
!define PROJECT_VERSION "4.23.9-SNAPSHOT"
which is used in my setup.nsi:
!include target\project.nsh
Section VersionReplace
Push "${PROJECT_VERSION}"
Push "-SNAPSHOT"
Push "0"
Call StrRep
Pop $0
!define VERSION_SHORT $0
SectionEnd
Name "Installer ${VERSION_SHORT}"
(...)
VIProductVersion ${VERSION_SHORT}
Problem : In the Console i can see:
Name: "Installer $0"
(...)
VIAddVersionKey: "ProductVersion" "$0"
so the $0 is not replaced. What am I doing wrong?
Replacement function used: StrRep
这可以使用!searchreplace命令来完成,该命令在编译时运行
!searchreplace PROJECT_VERSION_SHORT ${PROJECT_VERSION} "-SNAPSHOT" ".0"
The Name
and VIProductVersion
are installer attributes that are taken into account at compile time while creating the .exe
The StrRep
function will be called at runtime when passing into the section VersionReplace
, and it will be too late to change Name
or VIProductVersion
.
BTW: if you want to define some value at runtime like in your !define VERSION_SHORT $0
statement, create a variable with the Var
statement and modify the variable (with StrCpy
). A !define
is a string replacement defined during compilation that cannot change. What you have actually written is that VERSION_SHORT
is an alias for $0
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.