We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

awatt
Posts: 7
Joined: Thu Dec 15, 2005 12:36 am
Location: Lincoln, Nebraska

Dependent files/component

I've got a scenario that seems simple, but I can't figure out how to do it properly in Advanced Installer.

What I've got is a file to be installed in one directory, and another group of files to be installed in subdirectory of that. The second group is dependent on the first file, and they should always be installed or skipped in conjunction with the first. Reinstalling the first without reinstalling the others or vice-versa will break functionality.

Now if I could put them all in the same component and make the first file the key, that would be perfect. But of course, since they're in separate directories, that's not possible.

I tried to set a condition on the second file group's component to install depending on the component action of the first, but it didn't seem to work--they never install.

So, what is a good way to go about this? Any ideas?
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

Have you try to use in the "Organization" page the following condition: $Component1 = 3 (check if the Component1 is locally installed on the computer) for the Component2 (component of the second group of files).

Please try this and let me know if this solves the problem.

Regards,
Gigi
________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
awatt
Posts: 7
Joined: Thu Dec 15, 2005 12:36 am
Location: Lincoln, Nebraska

I have indeed tried that. The second group is never installed, regardless of whether the first is.

Here's a snip from the log:

Code: Select all

MSI (s) (4C:64) [14:45:02:734]: Component: Component2; Installed: Absent;   Request: Local;   Action: Null
MSI (s) (4C:64) [14:45:02:796]: Component: Component1; Installed: Absent;   Request: Local;   Action: Local
'Component1' is actually the name of the first file's component, and 'Component2' is actually the second group's component.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

I think that you use a condition for the installation of the first component. Then use the same condition for the second component too. If this does not solves the problem then please tell me how you condition the installation of the first component.

Regards,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
awatt
Posts: 7
Joined: Thu Dec 15, 2005 12:36 am
Location: Lincoln, Nebraska

Hmmm... alright, I want the first component to have a condition like this: if the file does not already exist, then install it; otherwise, do not install it. How can I make a condition like that? Do I need to set a property in a custom action, or is there an easier way?

By the way, I have both components marked as "Permanent," if that makes a difference. I did that because I don't want them to be removed during an uninstall, or replaced during an upgrade.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,
By the way, I have both components marked as "Permanent," if that makes a difference. I did that because I don't want them to be removed during an uninstall, or replaced during an upgrade.
Then you can use "Permanent" and "Never Overwrite" flags for the components and then you don't need an extra condition. Because with those flags set the components are get installed only if they are not already installed. I think this is the best approach in your case.

Regards,
Gigi
__________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
awatt
Posts: 7
Joined: Thu Dec 15, 2005 12:36 am
Location: Lincoln, Nebraska

That's not what I want to do.

The whole idea is to get Component1 and Component2 to always install together. If the first installs, so does the second. If the first does not install, the second does not either. The second has to depend on the first.

The "Never Overwrite" flag will only work on each component individually. So it doesn't help me.

I have discovered that if I set up a custom action in CostFinalize of type Error Message, and use the condition '$Component1 = 3', the message will be triggered. But for some reason this doesn't work for Component2's condition. Is this possibly a bug?
awatt
Posts: 7
Joined: Thu Dec 15, 2005 12:36 am
Location: Lincoln, Nebraska

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.

Return to “Common Problems”