Stijn1derBeek
Posts: 7
Joined: Mon Aug 30, 2021 1:41 pm

Property in filenames/paths doesnt respect updates to the given property

Mon Aug 30, 2021 1:58 pm

Hello,

I'm experiencing an issue described in the title. Properties seemingly initialize at an early stage, or later assigned values doesn't update the property in some areas.

Steps to reproduce:
New project, add file, and add [|ProductName] to the filename field.
First installation works as expected.
On multiple instance installation next installations still have the original ProductName instead of the Instance name.

This doesn't just apply to multiple instances, it can be triggered via using a custom property during dialog stage, the file get installed with default value.


Expected behaviour:

File or path respects the new value, and updates the property's value and retains this value during the installation execution stage. In the end files using an updated value in their filename.

Thank you in advance.

Stijn1derBeek
Posts: 7
Joined: Mon Aug 30, 2021 1:41 pm

Re: Property in filenames/paths doesnt respect updates to the given property

Fri Sep 03, 2021 11:02 am

Can you confirm this issue is reproducible on your side as well, or I'm the only one who experiencing this behaviour?

Regards,
Stijn

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Property in filenames/paths doesnt respect updates to the given property

Fri Sep 03, 2021 11:36 am

Hi Stijn,

Unfortunately, we do not have built-in support for what you want.

The "[|ProductName]" is a PseudoFormatted string. Properties referenced by PseudoFormatted data types are resolved at build time.
So, this is the expected behavior, you can not change these properties during install time.

During the installation you need to use only properties referenced by Formatted data types, for example "[ProductName]". But unfortunately, the name field of our "Edit File" does not support Formatted data types.

As a workaround, you can use a custom action to rename the file. For example this custom action can be a PowerShell script or even a batch file. Add the custom action in the "Install Execution Stage", after "Add Resources" action group. Also it must have the Execution Time → "When the system is being modified (deferred)".

Hope this helps! If you have any other questions, please don't hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Stijn1derBeek
Posts: 7
Joined: Mon Aug 30, 2021 1:41 pm

Re: Property in filenames/paths doesnt respect updates to the given property

Tue Sep 21, 2021 2:53 pm

Well... that is rather inconvenient. For other poor souls who try to place desktop icons with multiple instances:

Code: Select all

Param(
    [Parameter()]
    [string]
    $appdir,
    [Parameter()]
    [string]
    $prodname
)

$SourceFilePath = $appdir + "\filename.exe"
$ShortcutPath = "${env:PUBLIC}" + "\Desktop\software - " + $prodname + ".lnk"
$WScriptObj = New-Object -ComObject ("WScript.Shell")
$shortcut = $WscriptObj.CreateShortcut($ShortcutPath)
$shortcut.TargetPath = $SourceFilePath
$shortcut.Save()
With "Parameter values:"

Code: Select all

-appdir "[APPDIR]" -prodname "[ProductName]"
If you try to do it as a systemwide install (like me), Execution time should be set as deferred and Execution option "Run under the LocalSystem account..." should be enabled.

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: Property in filenames/paths doesnt respect updates to the given property

Tue Sep 21, 2021 3:20 pm

Hello Stijn,

Thank you for your followup on this and for sharing your solution with us!

I am sure other users facing a similar scenario will find this useful.

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

Return to “Common Problems”