0

I'm making an msi that installs 2 plugins to the user's Roaming folder and one folder (+ its content) to a particular location on a machine: C:\UMI\temp. For the 2 plugins, everything is fine. It's with the folder that I have an issue. First, I need to test if the location exists, and then move the content to that location.

The way I have it setup, I use Heat.exe to harvest the content of the folder inside a Merge Module. The merge module is then referenced inside my WIX Project File.

This is the content of the problematic merge module:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Module Id="TempFilesMM" Language="1033" Version="1.0.0.0">
        <Package Id="9f5b21ce-db22-40aa-a2f6-f82ed89958a5" Manufacturer="Some Company" InstallerVersion="200" InstallScope="perMachine"/>

        <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="MergeRedirectFolder">
        <Directory Id="INSTALLLOCATION" Name="HarvestSetup">
          <Directory Id="TempFilesComponentGroup">
          </Directory>
          </Directory>

      </Directory>
        </Directory>
    <ComponentGroupRef Id ="TempFilesComponentGroup"/>
    </Module>
</Wix>

Knowing TempFilesComponentGroup is the reference to the harvested .wxs file, I suppose INSTALLLOCATION is the directory where the content is copied during installation. As a matter of fact, on installation, it creates a folder called HarvestSetup on the root of the C:\ directory. I want it to install in C:\UMI\temp without the folder named HarvestSetup and also test if the location exists beforehand. Any suggestions?

Thanks a lot!

1 Answers1

0

Use a DirectorySearch to check if the folder exists:

<Property Id="EXISTING_INSTALLLOCATION">
    <DirectorySearch Id="Search_EXISTING_INSTALLLOCATION" Path="C:\UMI\temp"/>
</Property>

It seems a little bit strange that you want to install to a hard-coded path, but let's assume you have a good reason for that.

Use the property that is assigned by that DirectorySearch in the component condition to install files only if that directory exists.

<Component Id="SomeComponentId" Guid="SomeGUID" Directory="EXISTING_INSTALLLOCATION">
    <File Id="SomeFileId" Source="SomeSource"/>
    <Condition>EXISTING_INSTALLLOCATION</Condition> 
</Component>
zett42
  • 25,437
  • 3
  • 35
  • 72