Include version info in Installer#2409
Include version info in Installer#2409SinghRajenM wants to merge 1 commit intonotepad-plus-plus:masterfrom
Conversation
|
|
||
| !define CompanyName "Don HO don.h@free.fr" | ||
| !define Description "Notepad++ : a free (GNU) source code editor" | ||
| !define Version "7.0.0.0" |
There was a problem hiding this comment.
This is yet another place to modify when a new version comes out. Why not use the macros above?
There was a problem hiding this comment.
If you are talking about existing macro APPVERSION, it can't be used directly as VIProductVersion expect version string X.X.X.X. We have to write many conditions to utilize APPVERSION.
Reason is:
In V7 APPVERSION = 7
In V6.9.2 APPVERSION = 6.9.2
In V6.9 APPVERSION = 6.9
There was a problem hiding this comment.
I think he ment using something like ...
!define Version VERSION_MAJOR "." VERSION_MINORinstead of ...
!define Version "7.0.0.0"There was a problem hiding this comment.
However, I was thinking why can't we remove macro APPVERSION (VERSION_MAJOR and VERSION_MINOR as well). Instead of changing its value for every release, just read the version info from notepad++.exe and use it.
This requires an additional nsis file (get version of npp exe and write version info in normal text file in form of macro with required format.) and its output (exe) file.
Later include call this exe in beginning of nsi script to generate text file and use these defined macro from the text file.
We have used this approach in many project. This will reduce the manual effort of writing version info everytime.
There was a problem hiding this comment.
@MAPJe71 Initially, I though to utilizing existing macros, but when I saw the history of these macros, I could not use these without writing conditions as the value. Consider V6.9.2, then major is 6, minor is 92. So break 92 as 9.2 and append .0 (6.9.2.0) while in V7 major is 7, minor is 0, so append .0.0 (so 7.0.0.0).
Reduce human effort by reading verion info from npp exe itself and use it
c5bb9bd to
42f342b
Compare
|
|
||
| !define APPVERSION "7" | ||
| !system "nsisInclude\GetVersion.exe" | ||
| !include "VersionInfo.txt" |
There was a problem hiding this comment.
Now, version info can be read from npp.exe itself. No need to update this file for every release (at-least for version change).
MAPJe71
left a comment
There was a problem hiding this comment.
I assume the GetVersion.exe binary is generated from GetVersion.nsi during the build process so there's no need to add the binary to the repository.
| SetAutoClose true ; it simply writes version info in the text. So close immediatly after writing version info | ||
|
|
||
| DetailPrint "Getting version from ${EXEPATH}" | ||
| GetDllVersion "${EXEPATH}" $R0 $R1 ; Two values were read during compilation |
There was a problem hiding this comment.
The trailing comment doesn't make sense to me ...
- which two values?
- during compilation of what?
There was a problem hiding this comment.
Two values $ R0 and $ R1 which will be extracted from npp.exe.
There was a problem hiding this comment.
I get that the two
- ProductVersion and FileVersion?
- major and minor version?
- ...
There was a problem hiding this comment.
No still doesn't answer my question!
I can only presume that you mean that $R0 will contain the file version i.e. 6.9.2.0 and $R1 will contain the Product name i.e. Notepad++ as that are the values in the red box.
If that's the case I would have written the line of code as ...
GetDllVersion "${EXEPATH}" $R0 $R1 ; Get file version and product name respectively There was a problem hiding this comment.
No...no
Say npp.exe version 6.9.2.0, then
$R0 = 6.9 $R1=2.0
Below link you give you more insight
http://nsis.sourceforge.net/GetDllVersion_Command_Explained
From URL
About numbers GetDllVersion. First 16 bit of first number is major version. Second 16 bit of first number is minor version. First 16 bit of second number is release version. Second 16 bit of second number is build version.GetDLLVersion "MyApp.exe" $R0 $R1
IntOp $R2 $R0 >> 16
IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
IntOp $R4 $R1 >> 16
IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
There was a problem hiding this comment.
Finally the explanation I was looking for 👍
I suggest ...
GetDllVersion "${EXEPATH}" $R0 $R1 ; Get 32-bit values with major+minor and release+build respectively| GetDllVersion "${EXEPATH}" $R0 $R1 ; Two values were read during compilation | ||
|
|
||
| ;${GetFileVersion} "${EXEPATH}" $R0 | ||
| ;DetailPrint "Another way to get version: $R0" |
There was a problem hiding this comment.
Why another way?
Pick one and don't mention other way(s) or mention the other way(s) and comment/explain why it's not the preferred way. Don't create confusion!
There was a problem hiding this comment.
I don't think commented code creates confusion. If it really bothers people I'll remove commented code.
There was a problem hiding this comment.
I was trying different options and commented code was one of them. Instead removing, I just commented. Nothing more than that.
There was a problem hiding this comment.
As I wrote before pick one method/solution to be included in the official repository through a PR.
Keep tries to your local development environment.
| ; $1 = 7.0.0.0 (File Version) | ||
| ; $2 = 7.1.2 (Product Version) | ||
| ; $3 = 12 (Minor Version) | ||
|
|
There was a problem hiding this comment.
I think it's wise to get confirmation about the meaning of the different parts of the version number first i.e. before issuing a PR.
There was a problem hiding this comment.
There is no assumption. These all are facts from the previous releases
In V7 APPVERSION = 7 major=7 minor=0
In V6.9.2 APPVERSION = 6.9.2 major=6 minor=92
In V6.9 APPVERSION = 6.9 major=6 minor=9
There was a problem hiding this comment.
Correct about APPVERSION but AFAIK FileVersion and ProductVersion are always the same for Notepad++.
There was a problem hiding this comment.
No. They are not same. Refer the screenshot (attached above) of actual notepad++.exe. You will find the difference.
I think that make sense.
There was a problem hiding this comment.
Product version and File version are the same (see Notepad++ resource file).
But there's a difference in notation for the VERSION_DIGITALVALUE and the VERSION_VALUE.
The property list of the Notepad++ v6.9.2.0 executable will show the digital value (i.e. comma-separated-digits) as dot-separated-digits (e.g. 6.9.2.0) and the textual value will be visible as defined in the resource file i.e. 6.92.
Maybe it's possible for the NSIS script to read the version directly from the Notepad++ resource.h file?
There was a problem hiding this comment.
Need to investigate if it is possible to extract from resource.h.
URL: https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx might be helpful to understand versioning.

There was a problem hiding this comment.
What Windows version is that?
Strange that it shows the digital/fixed value for File version and textual/variable for Product version.
Yep, I've used automatic generated resource info in projects based on the linked MS info.
Notepad++ version numbering is not the same as MS tends to do it.
Here are some different methods I've seen over the years:
- Windows uses : major.minor[.build[.revision]]
- .NET uses : major.minor[.revision[.build]]
- other used formats : major.minor[.maintenance[.build]]
major.minor[.build[.((majorRevision && 0x00FF)<<8)||(minorRevision && 0x00FF)]]
major.minor[.patch[.stage]]
More recent I've encountered projects mentioning they use Semantic Versioning.
| StrCpy $2 "$R2.$R3.$R4.$R5" | ||
| StrCpy $3 "$R3$R4$R5" | ||
| ${Endif} | ||
|
|
There was a problem hiding this comment.
Would be nice if it's possible to give the variables explanatory names.
There was a problem hiding this comment.
I use these register variables because
: No declaration needed (var blah).
: Less LOC
: No name conflict (not applicable here very less code)
: Bit faster than normal variable
There was a problem hiding this comment.
I don't think it's a time critical part and self explanatory code is preferred (see Style Guide)
There was a problem hiding this comment.
This is way most of the nsis scripts are written. I feel these were introduce to simplify the task, otherwise there was no need to introduce registers $0~$9 and $R0~$R9.
|
Yes. It is generated from GetVersion.nsi but not during the build process. On Oct 13, 2016 4:27 AM, "Menno Vogels" notifications@github.com wrote:
|
|
IMO binaries in a repository are security liability but sometimes you can't get around them e.g. 3rd party libraries/tools. In this case the source is part of the project so I'd say build it during the build process but I'll leave that decision to @donho. |
I feel it is not that much easy, moreover I don't how appveyor is configured. But if I take an example from Jenkins, it requires two jenkin jobs.
In this case, job 1 will be slave job of job 2. So first job 2 should trigger job 1. Once job 1 is completed, move the artifact (GetVersion.exe) from job 1 to job2 and execute it which will write version info in form of macros. |
|
Notepad++ build already has two dependencies, the Boost and Scintilla libraries, so it shouldn't be a problem for the AppVeyor build environment. |
If so, then GetVersion.nsi should be built in different job and artifact can be moved to "PowerEditor\installer\nsisInclude" before starting npp setup creation build. Sorry, I don't how to create jobs and dependencies in AppVeyor as we have dedicated build engineers. |
|
About AppVeyor, the configuration is here : notepad-plus-plus/appveyor.yml link
You can execute before this command the compliation of GetVersion.nsi then use your getVersion program to do what you want to do. However, appVeyor is not used to build the notepad++ installer. It can't due to code certification. I hope it helps you |
|
I'd like also to have the git version to identify each version available (in case of people uses a nigthly build) => My repository HEAD is on version 7, 36 commits since tags, sha1 = 4fec265 |
|
It's a small "Nice to have" feature. However, it's not worth to me to integrate all the codes for adding this small feature. |
|
No problem!!! |

As of now, there is no version info available on the detail section of installer properties.
It is good to have version info.