casster
casster

Reputation: 31

Wix Toolset - how to install a file to a completely different directory and not as a root subdirectory?

For my application, most of the files need to be installed to a directory in ProgramFiles, and one other file needs to be installed in a directory in AppData/Local.

Here is an example of what I have so far:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="Folder1" />
        </Directory>
    </Directory>
</Fragment>

  
<Fragment>
    <ComponentGroup Id="AppID" Directory="INSTALLFOLDER">
        <Component Id="AppID">
             <File Source="$(var.myApp.TargetPath)" />
        </Component>
        <Component Id="OtherFile" Guid="INSERT-GUID_HERE">
            <File Id='OtherFile' Name='OtherFile' Source="otherfile" KeyPath='yes' />
        </Component>
        <Component Id="CopyId">
            <CopyFile Id="CopyId" FileId="OtherFile" 
                    DestinationDirectory="LocalAppDataFolder" />
        </Component>
</Fragment>

I've tried to copy the other file to AppData/Local but this won't compile and gives the error:

Unresolved reference to symbol 'Directory:LocalAppDataFolder' in section 'Fragment:'

Ideally, I want the other file to be in directory in AppData/Local, and not in ProgramFiles at all.

Upvotes: 1

Views: 1077

Answers (1)

Stein &#197;smul
Stein &#197;smul

Reputation: 42246

Application Launch: Consider doing file-copying on application launch instead of as part of the setup. Easier to implement, debug and change as you need to.


Fix: Try just adding this directly under the TARGETDIR element. This ensures that the standard directory LocalAppDataFolder is part of the compiled MSI file's Directory table:

<Directory Id="LocalAppDataFolder" Name="AppData">

Alternatively, here is a larger mock-up:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="SetupProject2" />
  </Directory>
  <Directory Id="LocalAppDataFolder" Name="AppData">
    <Directory Id="AppRootDirectory" Name="MyApplication">
      <Component Id="Test" Feature="ProductFeature" Guid="{11111111-1111-1111-1111-A73067A1AE95}">
        <RemoveFolder Id="AppRootDirectory" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\Something" Name="Flag" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </Directory>
  </Directory>
</Directory>

Upvotes: 1

Related Questions