cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rmikebaker
Level 3

Replacing text in files copied using XCopyFile

I'm creating an InstallScript MSI project that copies additional files to the target system from a custom external folder located on the installation media. I also need to perform text replacement in some of these files.

My issue is that I can't figure out where in the Execute sequence I need to copy the files so that I can take advantage of the built-in Text Replacement feature. I'm already using this feature to replace text in files that are copied to the target system based on Features/Components, so I'd just like it to update the 'custom' files as well.

I've tried using the 'Installed' event for the Feature, as well as the 'OnInstallFilesActionAfter' event, but I'm not having any luck. The sequence I need to achieve is:

1) Copy files from Features to target system (standard action/behavior)
2) Copy files from 'custom' folder to target system (custom - some of these may overwrite files copied from step 1)
3) Replace text in some of the installed files based on installer properties (standard action/behavior)

Where should I perform step 2 ?

Thanks!
-Mike
Labels (1)
0 Kudos
(3) Replies
weakness
Level 6

Apparently, [Text Replacement] feature is invoked from custom action [ISSearchReplaceInstall] as deferred.

So, your custom action should be located before the custom action.

Or I'm not sure,but why don't you write the custom code in 'Installing' rather than 'Installed' feature event?
0 Kudos
rmikebaker
Level 3

weakness wrote:
Apparently, [Text Replacement] feature is invoked from custom action [ISSearchReplaceInstall] as deferred.

So, your custom action should be located before the custom action.

Or I'm not sure,but why don't you write the custom code in 'Installing' rather than 'Installed' feature event?


Thanks for the reply.

I'll try another custom action, but my previous attempts have failed. I originally had code in the 'Installing' event handler, but that's called BEFORE the feature is installed, and I need to copy files AFTER the feature is installed. The 'Installed' event seemed to be occuring after the text replacement action had been executed, so none of my text was replaced.

I'll post if I have luck with a custom action...
0 Kudos
rmikebaker
Level 3

Ok - Finally got it working. I added a custom action after WriteEnvironmentStrings, which is right before ISSearchReplaceInstall.

Had to figure out how to pass the two folder paths using CustomActionData, as the regular properties didn't work at that point (should they?).

Also needed an install condition so that it didn't get executed during uninstall.

I'd be curious to here comments from others as to whether this seems like the 'correct' way to implement this.

Thanks in advance!
0 Kudos