Alright, here's what I've determined to be an adequate solution.
Apparently you cannot use component actions like $Component1 until after the CostFinalize step. You can't use them in other components' conditions, either (makes sense I guess, otherwise you could get a circular reference if components referenced each other).
So I set up two custom actions in the CostInitialize step.
1. Propery set with Formatted: set a property "MyFilePath" to the path of the file in Component1. You can't use references to installed files here, because they won't work until later (CostFinalize IIRC). So I hardcoded the path.
2. Attached this script:
Code: Select all
Function TestMyFile
Dim fso, myfile
Set fso = CreateObject("Scripting.FileSystemObject")
myfile = Session.Property("MyFilePath")
If (fso.FileExists(myfile)) Then
Session.Property("MyFileExists") = "TRUE"
Else
Session.Property("MyFileExists") = "FALSE"
End If
End Function
Now I have a property "MyFileExists" set to whether or not the file in Component1 exists, and it's done before the component conditions are evaluated (which seems to happen between IsolateComponents and CostFinalize).
Finally, I set the condition for both Component1 and Component2 to 'MyFileExists = "FALSE"'. And it seems to work correctly. If I'm doing something bad here, please let me know.
Now having done all this, I have a suggestion. It would be nice if AI could warn you if you're using properties or references before they are ready. For example, you can put $Component1 in component conditions and [#MyFile] references in custom actions before they're initialized, and AI happily goes along with it. But, these will never work. If AI had said something like "You are using a file reference before it will be initialized. This expression may not be evaluated properly. Are you sure you want to do this?" or "You cannot reference a component action inside another component's condition" instead of naively playing along, it would have helped me
a lot. At the very least, there ought to be something in the documentation about it.
FOLLOW US
Get the latest news in Application Packaging