0
votes

As per requirement of our product install, we need to install some dlls in C:\Windows\System32 in user's computer. Since Windows Installer automatically installs the higher version if source has a version higher than destination and in doing so modifies the user's system without user's knowledge, I want the component block to not fire at all when the dll is already present in C:\Windows\System32. That's why I'm doing a FileSearch and setting a property to a value in case the file exists. According to documents, it will be the path of the file specified.

    <Property Id="VCOMP_EXISTS_LOCAL">
      <DirectorySearch Id="vcomp_parent_dir" Path="$(var.SystemPlatformFolder)">
        <FileSearch Id="vcomp_file" Name="vcomp140.dll"/>
      </DirectorySearch>
    </Property>

Later on I'm using the VCOMP_EXISTS_LOCAL property, as in the following block to install the component conditionally.

    <ComponentGroup Id="AdditionalDependencies" Directory="$(var.SystemPlatformFolder)">
        <?if $(var.vcomp140_exists) = "true"?>
            <Component>
              <Condition>NOT VCOMP_EXISTS_LOCAL</Condition>
              <File Source="$(var.AdditionalDependenciesRoot)/OpenMP/vcomp140.dll"/>
            </Component>
        <?endif?>
    </ComponentGroup>

Issue is that when I tested it for the case when the file is present in destination, I see that my installer file, which is higher version, has replaced the file in destination, whereas according to above logic, it shouldn't have touched it. Also I don't see the property value echoed out in the verbose log. All I see in the log is this

AppSearch: Property: VCOMP_EXISTS_LOCAL, Signature: vcomp_file

and not something like following which is usually the case.

Property(S): VCOMP_EXISTS_LOCAL = C:\Windows\System32

The outer conditional pre-processor directives are to check for another condition, where var.vcomp140_exists is passed to candle.exe during compile (with the -d switch). So this is a build/compile time condition. I know that outer condition works (value passed is true). Looks like the inner install time condition block is being ignored by WI. Can you mix it up like this?

In case you can, I guess my issue is not knowing how to check for whether property value is set or not. I found somewhere in Wix document that, If search fails, property will remain undefined or it will keep its original value. In this case, I guess it will be undefined. Question is if 'NOT PROPERTYNAME' is how you check it? Any help will be much appreciated. Stuck on this issue for days!

2

2 Answers

0
votes

The syntax you are using as a conditional is a preprocessor, its resolved at build time, not runtime. You need to craft a conditional with an appropriate expression that is evaluated after the file search.

0
votes

Quite apart from the component condition situation, there is no need to do this. The standard way to distribute the VC++ redistributables is to run the redist package as a prerequisite. When you say "my installer file, which is higher version, has replaced the file in destination" then you shouldn't be doing it at all. You risk breaking the client system.

I also note that a shared Dll like that is shared using a Windows Installer component id, so that every product that uses something like vcomp140.dll will install it with the same component id. Again, you risk breaking the sharing for that Dll by just installing it with your own component id.

The correct action is to run the redist as a prerequisite and it will just do the right thing.