chrisdk781
Posts: 5
Joined: Thu May 16, 2019 4:53 pm

Files And Folders dynamic folder

Hello,

New to AI and building a setup for the first time. I tried digging through searches and forum to find an answer but not specifically what I am attempting.

In the files and folders i would like to add a folder under Application Folder that is in a dynamic location, is this possible? Here is the scenario.
A build machine has no code paths only a build agent.
When triggered the build agent creates a code path and downloads the source. (sometimes C:\agent\1\working\source\)
The tricky part here is the agent could use another location depending on if other builds are in progress, so it would change to C:\agent\2\working\source\
Note the number change in the directory path from 1 and 2.
The code is compiled into two folders Server and Terminal.
Then our current process an NSIS build is performed, it resides in the agent source folder so it does a ..\..\Server\* command which grabs everything in the Server folder and then terminal folder respectively.
Is something like this achievable in AI? I have looked through the folder sync but its not exactly what i need.
Reading about the paths state when the AI setup file is moved to another location such as this scenario it would alter the location of the files it searches for so would i need to build it and specify the folder and files two directories below the main aip and when copied it would alter to where i need it?

thank you for any help
Chris
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: Files And Folders dynamic folder

Hello Chris and welcome to Advanced Installer forums,

First of all, please accept my apologies for the delayed reply, but we were quite busy lately.

In what regards your requests, if I understand correctly, you want to set a property based folder value based on a custom condition. One thing that confuses me a bit here is the following: would you like to set this folder's value at build time or at install time? If it's the first one, I am afraid I am not aware of any method in which you can achieve that.

If it is the second one, I think that this can be done through a custom action. The standard action that ends the disk space costing and resolves the folders in the project is called "CostFinalize", which means that our custom action should be scheduled before it.

The "CostFinalize" standard action is part of the "Paths Resolution" action group (in "Wizard Dialogs Stage"). In order to reveal it, so you can properly schedule your custom action, you can proceed as it follows:

- go to "Custom Actions" page

- right click on "Paths Resolution" action group --> "Show Standard Action" --> "Paths Resolution" --> click on "CostFinalize"

Now let's talk a bit about the custom action. Here we will need a custom action with sequence. In order to add a custom action with sequence, all you have to do is to press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

The custom action can be of any kind, e.g. a PowerShell script, a VBScript, a C# custom action, etc.

For instance, let's say that you would use a PowerShell inline script custom action. In order to add this, please proceed as it follows:

- go to "Custom Actions" page

- add the "Run PowerShell inline script" custom action with sequence.

- schedule it before the "CostFinalize" standard action (from "Wizard Dialogs Stage"). To do so, simply drag and drop it before the previously mentioned standard action.

In what regards the custom action content, I will try to give you a brief example on how this could be done:

This custom action will set the value of a property based on a variable value.

Code: Select all

$var = 1

if ($var -eq "1"){

AI_SetMsiProperty MY_PROP "C:\something\"

}

elseif($var -eq "2"){

AI_SetMsiProperty MY_PROP "C:\something2\"

}
where MY_PROP is the property on which the property based folder is built. At install time, when the custom action will be executed, the value of the folder will be, in this case "C:\something", because the value of the "$var" variable is "1".

Hope this helps somehow.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”