@@ -392,17 +392,33 @@ jobs:
392392 <Binary Id="ShowMessageScript" SourceFile="SourceDir/ShowSuccessMessage.vbs" />
393393 <CustomAction Id="ShowSuccessMessage" BinaryKey="ShowMessageScript" VBScriptCall="" Execute="immediate" Return="check" />
394394
395- <!-- Custom Action: Write WORKSPACES_FOLDER to settings file -->
396- <CustomAction Id="WriteWorkspacePath" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no"
397- ExeCommand="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "`$settingsPath='[AppSubFolder]settings.json'; `$settings = Get-Content -Raw `$settingsPath | ConvertFrom-Json; `$settings.workspaces_dir = '[WORKSPACES_FOLDER]'; `$settings | ConvertTo-Json -Depth 100 | Set-Content `$settingsPath""
398- Return="check" />
395+ <!-- Step 1: Pass variables to CustomActionData -->
396+ <CustomAction Id="SetWriteWorkspacePathData"
397+ Property="WriteWorkspacePath"
398+ Value="AppSubFolder=[AppSubFolder];WORKSPACES_FOLDER=[WORKSPACES_FOLDER]" />
399+
400+ <!-- Step 2: Actual PowerShell inline script -->
401+ <CustomAction Id="WriteWorkspacePath"
402+ Directory="INSTALLFOLDER"
403+ Execute="deferred"
404+ Impersonate="no"
405+ Return="check"
406+ ExeCommand="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "
407+ $props = @{}; ('[CustomActionData]' -split ';') |
408+ ForEach-Object { $k,$v = $_ -split '=',2; $props[$k]=$v };
409+ $settingsPath = Join-Path $props.AppSubFolder 'settings.json';
410+ $settings = Get-Content -Raw -Path $settingsPath | ConvertFrom-Json;
411+ $settings.workspaces_dir = $props.WORKSPACES_FOLDER;
412+ $settings | ConvertTo-Json -Depth 100 | Set-Content -Path $settingsPath"" />
413+
399414 <!-- Add all Custom Actions -->
400415 <InstallExecuteSequence>
401416 <!-- Custom action display success message -->
402417 <Custom Action="ShowSuccessMessage" After="InstallFinalize">NOT Installed</Custom>
403418 <!-- Run app directly after installation -->
404419 <!-- <Custom Action="RunApp" Before="InstallFinalize">NOT REMOVE</Custom> -->
405- <Custom Action="WriteWorkspacePath" Before="InstallFinalize">NOT Installed</Custom>
420+ <Custom Action="SetWriteWorkspacePathData" Before="WriteWorkspacePath">NOT Installed</Custom>
421+ <Custom Action="WriteWorkspacePath"Before="InstallFinalize"">NOT Installed</Custom>
406422 </InstallExecuteSequence>
407423
408424 <!-- Interface options -->
0 commit comments