Wix 3.5 add file based on file exists or not

52 Views Asked by At

I’m currently trying to learn how to build a installer itself but have a hard time figuring it out.

I miss a concrete example of how an element is used, for example in my case am I needed to search for a file, if it is in a specific folder. Then if it is not, then will the file be added to the folder. Is the file already there is the step skipped.

Currently what I’m trying is I have added a property, where I later check if the property is set to false then will a file be added. The following code is inside the Feature tag, which is inside Product tag which is inside Wix:

    <Property Id="fileSearchExists">
        <DirectorySearch 
                  Path="dir_Settings"
                  Depth="0"
                  id="fileSearchFolderDirectory"  
                  AssignToProperty="yes">
          <FileSearch Id="GlobalSettingsSearching" Name="GlobalSettings" ></FileSearch>
        </DirectorySearch>
    </Property>
    <?if [fileSearchExists] = false ?>
        <Component Directory="dir_Settings_Shared" Permanent="yes" Id="C_$(var.GlobalSettingsFile)" KeyPath="yes" Guid="guidInsertedHere">
            <File Name="GlobalSettings" Source="$(var.GlobalSettingsPath)" />
        </Component>
    <?endif ?>

BR Kristine

If I run the above check does the file part not get ran. My global setting file is nowhere to be found.

Also if I install using command 'msiexec /i ' and write out the information in a log file, then can I not see my property anywhere either.

0

There are 0 best solutions below