Archive: Creating dynamic sections


Creating dynamic sections
Thanks first of all for viewing this thread as I know some of the seniors are thinking "why didn't he just search the forum?"

Fortunately I have and I don't think the solution of creating a "bunch" of empty sections and changing the name of that section at runtime is a solution for me.

Though I would think this problem would be one that is quite common I could be mistaken.

My example is that I want the sections that are available for selection to be based on if a directory or file exists.

One would hope there would be a insert section command of some sort but that doesn't seem to be the case.

Are there any solutions for this out there or another idea besides creating empty sections in the script prior to runtime?

Have a great day! :)


There are no other solutions. Sections are defined at compiletime. Your only option is to have a 100 hidden sections, and rename/unhide them at runtime. Why do you think this is not a solution for you?


Thanks for the reply.

For our particular install case, if a plugin developer creates a new project (which per plugin is simply a dll, pdb and dependency folder) then we want that new plugin to appear by the name of the folder ( or file doesn't really matter) the next time a build occurs. This would allow new plugins to be created and be picked up by the installer without someone having to modify the nsi script.

Arbitrarily added x number of sections could mean that you reach a limit of the sections and have to modify the script.

If this is the only solution, though, is there any overhead of creating so many blank sections that will not be used during that time?


Aha, so you want to create sections depending on files present at compile time? As far as I know there are no compiletime commands in NSIS that allow you to enumerate compiletime files/folders, so you'll need to run an external script/exe that generates nsi code depending on file existence. See this thread: http://forums.winamp.com/showthread.php?t=332913

(You can execute exes, vbs scripts, etc during compilation using the !system command.)


My suggestion is to not think of your plugins as equating to NSIS sections.

Just create a custom page with a treeview control, where each of your plugin folders is shown as an item in the tree. Allow the user to select or unselect them, and then read the tree settings when the page is left (when Next is clicked). Having read the settings, you can process them (when Install is clicked) in one section.

You don't need dynamic sections at all. Your script will enumerate the parent folder to find the plugins and display all of them in the treeview.

Don


Originally posted by MSG
Aha, so you want to create sections depending on files present at compile time? As far as I know there are no compiletime commands in NSIS that allow you to enumerate compiletime files/folders, so you'll need to run an external script/exe that generates nsi code depending on file existence. See this thread: http://forums.winamp.com/showthread.php?t=332913

(You can execute exes, vbs scripts, etc during compilation using the !system command.)
Originally posted by demiller9
My suggestion is to not think of your plugins as equating to NSIS sections.

Just create a custom page with a treeview control, where each of your plugin folders is shown as an item in the tree. Allow the user to select or unselect them, and then read the tree settings when the page is left (when Next is clicked). Having read the settings, you can process them (when Install is clicked) in one section.

You don't need dynamic sections at all. Your script will enumerate the parent folder to find the plugins and display all of them in the treeview.

Don
This is a great design idea! I like this one the most because it would seem to have less maintenance. Thank you!

demiller9,

Do you have an example link you could provide something that would get me started for a similar solution? I am not well versed in NSIS.


Thank you both for your great suggestions! This will definitely help me accomplish my goals with our current installer.


Originally posted by demiller9
You don't need dynamic sections at all. Your script will enumerate the parent folder to find the plugins and display all of them in the treeview.
Err... That only works at runtime. He explained he wants to add sections automatically depending on files present during *compiling*.

I may have misunderstood his desire, but this is what I think he has asked to do: Create an installer that will show an 'unlimited' number of plugin choices (sections, he termed them). I read this to be some-random-app plugins, not NSIS plugins.

I suggested that the 'sections' are just a custom page with a treeview, and will be processed by a single NSIS section. The plugin files it will install have ALL been included in the installer using a wildcard on the parent folder, and could be temporarily extracted to the target system into the PlugInsDir. In that location the NSIS runtime can enumerate them and create the treeview entries. Extracting them to the PlugInsDir will ensure they will all be deleted when the installer terminates.

@MSG: your suggestion to use a vbscript to enumerate the plugins at compile time and generate NSIS code is perfectly sound. The generated code would define the sections to show the plugins and, inside the sections, file commands to install them. It will handle as many plugins as it finds. The benefit might be simpler coding (he doesn't need to code a custom page with a treeview); the extra vbscript code is only a small negative.

Don


Ah, I see what you mean now. Smart solution, although the temporary extraction at runtime might be a disadvantage, requiring HDD space before installation has begun. Personally I'd go for simple compiletime enumeration (could use an NSIS exe for that, even). But it's an interesting idea, to be sure.


I may not have explained this properly, do excuse me, but I did mean dynamically pull the folders files at the time of compiling the installer. Thanks again both, this has been very helpful.


Quote:


Such a very amazing link!

Originally Posted by MSG (Post 2794111) Aha, so you want to create sections depending on files present at compile time? As far as I know there are no compiletime commands in NSIS that allow you to enumerate compiletime files/folders, so you'll need to run an external script/exe that generates nsi code depending on file existence. See this thread: http://forums.winamp.com/showthread.php?t=332913

(You can execute exes, vbs scripts, etc during compilation using the !system command.)