Syusaku Takara
Posts: 14
Joined: Mon Nov 02, 2009 1:52 pm

how to create MAJORVERSION.MINORVERSION folder under Application Folder.

HI
I want to install files into a version numbered folder named without build number like below
ProductVersion is 1.1.1
Expected installation folder: c:\program files\MyCompany\MyApp\1.1

I'd like to generate 1.1 from Product Version to avoid a missing to update on Files and Folders page directory.
I created 2 properties like MAJOR=0 and MINOR=0 on Install Parameter page.
And I assign these onto for Target name : [|MAJOR_VERSION]_[|MINOR_VERSION] in Edit Folder dialog under Application Folder on Files and Folders page.
And I created custom Action as follows as VBScript on Execute InlineScript Code.

Code: Select all

Dim token
productversion = Session.Property("ProductVersion")
token = split(productversion, ".")

Session.Property("MAJOR_VERSION") = token(0)
Session.Property("MINOR_VERSION") = token(1)
Session.Property("BUILD_VERSION") = token(2)
And I put it on top of Custom Actions.

I run it without any error,but it installed c:\program files\MyCompany\MyApp\0.0
2 properties are updated properly, but folder name is using initial value of property.

Do you have any solution of this?

P.S
I applied same above steps for Application folder: field on Install Parameters page. the MAJOR property is reflected for folder name. But subfolder is still assigned initial value of property.

Thanks in advance.
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: how to create MAJORVERSION.MINORVERSION folder under Application Folder.

Hello,

First of all, please keep in mind that properties referenced by PseudoFormatted (the ones containing vertical pipes) data types are resolved at build time.

In order to achieve what you want, you can create a property based folder instead of a regular folder.

Here is a step-by-step which will help you achieve those said above:

1) First, we need to create the property which will store the path. To do this, you can go to "Install Parameters" page and click on the "New Property" button from the toolbar. Set its name to, for example, PV (product version) and its value to 0.

2) Now we will need to set our earlier created property value to have the value of the [APPDIR] property. In order to do so, you can use a "Set Property" custom action with the following arguments:
-Property: PV (our earlier created property)
-Value: [APPDIR]
-Execution Time: Immediately

2.1) As a side note, please keep in mind that in order for this to be achievable, we have to place the above specified custom action after the "SET_APPDIR" standard action. The "SET_APPDIR" standard action takes place before the "Cost Initialize" action, thus we will need to place our custom action after the "Cost Initialize" and before the "FileCost" standard actions. In order to do so, you can go to "Custom Actions" page --> right click on any action group from "Install Execution Stage" --> "Show Standard Action" --> "Paths Resolution" --> click on "Cost Initialize". Now repeat the steps presented earlier for the "FileCost" standard action.

After doing so, drag and drop the earlier created "Set Property" custom action between the "Cost Initialize" and "FileCost" standard actions.

3) Now we have to create the script which will create the major.minor folder under the application folder. Here is an example of a visual basic script which takes only the first two digits (the major and minor version) of the "ProductVersion" property:

Code: Select all

Dim token
productversion = Session.Property("ProductVersion")
token = split(productversion, ".")

Session.Property("PV") = Session.Property("APPDIR") & "\" & token(0) & "_" & token(1)
4) Now we have to share the earlier created custom actions between "Install Execution Stage" and "Wizard Dialogs Stage". In order to achieve this, Shift + Drag and Drop the custom actions from "Install Execution Stage" to "Wizard Dialogs Stage". Please make sure that the custom actions from the "Wizard Dialogs Stage" also take place between "CostInitialize" and "FileCost" standard actions as presented in point 2.1)

5) The last step is to create the "Property Based" folder. In order to do so, you can go to "Files and Folders" page --> right click on "Application Folder" --> "New Folder" --> "Property Based" --> select the property you created at point 1) and click "Ok".

6) Build and run.

Let me know if this helps!

Regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”