PortableApps.com Platform and Suite 1.6 have been released.

Custom Code with Installer

Submitted by prapper on June 12, 2009 - 2:22pm

OK, so I've got "PortableApps.comInstallerCustom.nsh" in the Other\Source directory and it contains -

!macro CustomCodePostInstall
MessageBox MB_OK|MB_ICONEXCLAMATION `hello`
!macroend

but I can't figure out why I'm not getting anything.


( categories: )

Fixed in 0.91.3

It was a bug in 0.91.2. It's fixed in 0.91.3.

Sometimes, the impossible can become possible, if you're awesome!

Wow, I found two bugs in one

Wow, I found two bugs in one day, I must be on a roll... Smiling and you guys fixed them within a couple of hours. That's what I love about this open source stuff... Smiling

Nice one(s)...

I still can't get it to work

I still can't get it to work though...

???

Is this a plugin installer?

I tried adding custom code to a plugin installer and none of it gets executed when I run it.

Yes it is... or was, rather

Yes it is... or was, rather Smiling

Is there any news on whether

Is there any news on whether this has been confirmed or not? I still can't get it to run with 0.91.4.

wfm

It works for me. Remember you need to name your custom code as PortableApps.comInstallerPluginCustom.nsh.

Sometimes, the impossible can become possible, if you're awesome!

Hmm... yes, I realised that

Hmm... yes, I realised that shortly after the inital post. I've just tried again, filename copied & pasted from your reply. The installer compiles, installs and downloads the files all fine (again) but still I don't get the custom code. Both files ("plugininstaller.ini" & "PortableApps.comInstallerPluginCustom.nsh" in Other\Source.

I am missing something here...

Right Macros

You sure you have the proper macros defined?

Sometimes, the impossible can become possible, if you're awesome!

Well I'm still using what's

Well I'm still using what's in the initial post at the moment plus the NSIS code required to copy then delete the files straight afterwards but I'm not even seeing the messagebox.

An update. I've got it

An update. I've got it running. It looks like there was something wrong with my nsh file as I copied all the code into a new file then resaved and that's sorted it out. But...

I'm using this...

CopyFiles /SILENT "App\AppName\DirA\*.*" "App\AppName\DirB"
RMDir /r "App\AppName\DirA"

The are 64 files in DirA but only the first 33 are being copied. I've tried altering the code to just move the 34th file to see if it's stumbling there for some reason but it works fine and I don't want to just rename DirB to DirA, in case there are going to be other files in DirA, so it has to be a copy then delete. Also, after they've been copied over, all the long filenames have been truncated to 8.3.

I haven't tried listing out all 64 files yet, for obvious reasons!

And after all that, DirA is not being removed.

Apologies for dragging this one out, perhaps this isn't an installer issue after all but I'm more baffled now than I was before Smiling Hopefully somebody can point out the obvious mistake I'm making.

Have you tried this?

CopyFiles /SILENT "App\AppName\DirA\*.*" "App\AppName\DirB\"

I had a quick grep through my NSIS code and it seems that CopyFiles likes a trailing slash in the destination when copying files. I also use the /FILESONLY flag if I only want files copied

Still no go I'm afraid.

Still no go I'm afraid. Thanks for the suggestions though.

OK, so I bit the bullet and

OK, so I bit the bullet and listed out all the files and they're all moved successfully now, filenames intact. However, I still can't delete the remaining empty directory.

Is there some reason why this...

RMDir /r "App\AppName\DirA"

wouldn't work in "PortableApps.comInstallerPluginCustom.nsh"?

ALWAYS absolute paths

In NSIS installers, you ALWAYS need absolute paths - otherwise enter erratic behaviour. This'll be why your CopyFiles goes weird as well. What you want is $INSTDIR\App\AppName\Dir[A|B] etc. Also look at Rename (I don't know if it's what you want, you may already have files in DirB; if you're just wanting to rename it though that's the way to go). As for a trailing slash, it's only useful in clarifying what a thing is. If the directory already exists, there'll be no problem with it.

I am a Christian and a developer and moderator here.

“It is in vain that you rise up early and go late to rest, eating the bread of anxious toil; for he gives to his beloved sleep.” – Solomon, Psalm 127:2

Thanks Chris, most helpful as

Thanks Chris, most helpful as always, that's sorted it out.

CustomCodeOptionalCleanup runs at the wrong time

According to the 0.91 (2009-06-11) specification CustomCodePreInstall is run before installation, CustomCodePostInstall is run after installation and CustomCodeOptionalCleanup is run after installation if the optional section of an installer is not selected. This is not how it works in Installer 0.91.3 - CustomCodeOptionalCleanup appears to be run before the installer does anything else.

I set each macro to display a message box showing the appropriate macro name:

With the optional component selected:

existing installation files removed
CustomCodePreInstall macro executed
main installation files installed
CustomCodePostInstall macro executed
optional files installed
installer finished

With the optional component NOT selected:

CustomCodeOptionalCleanup macro executed
existing installation files removed
CustomCodePreInstall macro executed
main installation files installed
CustomCodePostInstall macro executed
installer finished

Confirmed

I've confirmed this, but I haven't decided whether to change the spec or the installer. Ideally, it shouldn't matter as it's really designed for upgrades.

Sometimes, the impossible can become possible, if you're awesome!