Archive: Simple Tip To Add NSIS Source to Package


Simple Tip To Add NSIS Source to Package
  For those of you that love open source or just need a simple way to include the source code for your packages.

Just add this to the end of all your packages. It will be included as a file resource and if you use 7zip to extract your package you will find your source included. It's very basic but works great if you don't rely on a lot of custom includes.

Section/o -SourceCode

File`${__FILE__}`
>SectionEnd
>
Enjoy :D

Personally, I use the similar following trick instead :


Goto +2
File "myfile.nsi"

Originally posted by Wizou
Goto+2

File "myfile.nsi"
Ah nice, with the goto added it assures that it will never be extracted. Nice trick ;)

I put my source in with code like this:

Function .oninit
...
SetOutPath $PLUGINSDIR\Src
File ${__FILE__}
File buildnum.nsh
File ...
SetOutPath $Temp ; don't leave working dir in $Pluginsdir or it can't be deleted
FunctionEnd

This allows me to get the source from %temp%\ns????.tmp\Src without using 7-zip. Then the source will be deleted after the installer finishes.