peterk
Posts: 14
Joined: Wed Aug 03, 2022 3:23 pm

File modified during custom action goes back to original content

We upgraded to 21.5 from 20.0 and we are seeing a difference in behavior. We have a file that is set as not to overwrite during installation (upgrade).
settings on file that are not to be updated
settings on file that are not to be updated
Screenshot 2024-04-08 093435.png (11.68 KiB) Viewed 4471 times
This file is modified as one of our last custom actions by a powershell script. We can see in the logs and on disk the custom action fires and modifies the file but as the installer is finishing up the file goes back to the same file as was on disk prior to running the installer

How do we stop this revert behavior?

This folder and file path are added prior to build by the API with the following calls from a powershell script. This script has worked
in versions 19 and 20:

Code: Select all

& $ai_install /edit "$installer_path\$aip_project_file" /AddFolder "IISWWWRootFolder" "$ss_path"
& $ai_install /edit "$installer_path\$aip_project_file" /UpdateFile "IISWWWRootFolder\SS\appsettings.json" -overwrite no
Catalin
Posts: 6611
Joined: Wed Jun 13, 2018 7:49 am

Re: File modified during custom action goes back to original content

Hello Peter,

From your details so far, I am thinking that perhaps the PowerShell custom action executes and modifies the file prior to the custom action that reverts the file.

If you own an Enterprise license or above, we can check this by going to the "Table Editor" page --> "InstallExecuteSequence" table --> click on "Sequence" so we can order them.

After doing so, please check for your custom action and then look where it is scheduled in comparison with AI_AiRestoreDeferred action.
Screenshot_136.png
Screenshot_136.png (14.7 KiB) Viewed 3523 times
As we can see, this custom action is executed basically last in sequence, so chances are it will be executed after your PowerShell custom action.

The only strange thing is here is the fact that, as per your statement, it used to work in previous versions.

Perhaps someone scheduled the custom action and it's now executed before?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
peterk
Posts: 14
Joined: Wed Aug 03, 2022 3:23 pm

Re: File modified during custom action goes back to original content

ordered-sequence-AI.png
ordered-sequence-AI.png (18.59 KiB) Viewed 3516 times
This is our current order. The highlighted line is the custom action that fires that modifies the file. The one thing that we did do during the upgrade is we moved from having the custom powershell script go from inline to an external file that we call. In fact we moved all our custom actions from inline to external scripts so we could modify our project without having to go into AI all the time. Could this be the reason? If so do we change the sequence numbers manually?
Catalin
Posts: 6611
Joined: Wed Jun 13, 2018 7:49 am

Re: File modified during custom action goes back to original content

Hello Peter,

That might indeed be the reason why that happens.

And sure, we can modify the sequence number so we can fit our custom action in there.

For instance, we can increase the value of InstallFinalize from 6600 to 6605 and then have our custom action with the sequence 6601.
Screenshot_140.png
Screenshot_140.png (34.37 KiB) Viewed 2606 times

Our custom action should still be scheduled during the "Deferred" stage
Screenshot_141.png
Screenshot_141.png (52.12 KiB) Viewed 2606 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
peterk
Posts: 14
Joined: Wed Aug 03, 2022 3:23 pm

Re: File modified during custom action goes back to original content

Changing the sequence order in the Table Editor allows us to modify the file on disk and gets us past this issue. While I consider this solved, it will be a pain going forward for any engineer learning AI that they have to use the Table Editor for anything touching files that are set not to be overwritten.

One thing that I find that should be a bug is that we have a custom action (the very first one) that is set to immediate but it references a script that is on disk. The file hasn't been copied to disk yet by AI. This took awhile to debug as the log would just say "File not found".
Catalin
Posts: 6611
Joined: Wed Jun 13, 2018 7:49 am

Re: File modified during custom action goes back to original content

Hello Peter,

I am glad to hear everything is now working as you expected.
One thing that I find that should be a bug is that we have a custom action (the very first one) that is set to immediate but it references a script that is on disk. The file hasn't been copied to disk yet by AI. This took awhile to debug as the log would just say "File not found".
Regarding this, please note that there isn't a one fit for all solution. Even if we scheduled the custom action automatically as deferred, there is the case where the user can add the file as temporary, in which launching the file works just fine because temporary files are copied on the machine much earlier especially for that reason.

Thank you for your understanding!

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

Return to “Common Problems”