1

I´m using a Wix project to generate an installer MSI file.

My project needs to be installed in a specific folder (like C:\MyProject\Version1), not the default Program Files folder. My folder desired structure:

c:\MyProject\Version1
    |
    |--- MyProject.exe
    |--- Utils.dll
    |--- README.txt
    |
    |--- data
          |----- config.ini

Here is my Wix configuration:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><?define eMyProjectConnectionTest_TargetDir=$(var.eMyProjectConnectionTest.TargetDir)?><?define MyProject_TargetDir=$(var.MyProject.TargetDir)?><?define MyProjectCheckLicenses_TargetDir=$(var.MyProjectCheckLicenses.TargetDir)?>
    <Product Id="1609421b-de6a-4285-b190-861ce626ab5e" Name="MyProject" Language="1033" Version="3.3.0" Manufacturer="MyProject Software LLC" UpgradeCode="f1fb7395-ff04-4eb9-942b-5c6ff889808c">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <!-- EmbedCab="yes" adds the CAB file to the instlal file -->
    <MediaTemplate EmbedCab="yes"/> 

    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
      <!-- <Component Id="ProductComponent"> -->
      <!-- TODO: Insert files, registry keys, and other resources here. -->
      <!-- </Component> -->
      <Component Id="MyProject.exe" Guid="cbea4919-c7a7-4264-925f-7c7c58a952b3">
        <File Id="MyProject.exe" Name="MyProject.exe" Source="$(var.MyProject_TargetDir)MyProject.exe" />
      </Component>

      <!-- Added files -->
      <Component Id="Utils.dll" Guid="192fee52-79e1-43cb-81c8-b8af9d4d9ecc">
        <File Id="Utils.dll" Source="Files/Utils.dll" KeyPath="yes"/>
      </Component>

      <Component Id="README.txt" Guid="c8c74065-5dd9-44d0-83ab-8838bea143e3">
        <File Id="README.txt" Source="Files/README.txt" KeyPath="yes"/>
      </Component>

    </ComponentGroup>

    <!-- Adds a start menu shortcut -->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="MyProject">
          <Directory Id="data" Name="data">
            <Component Id="config.ini" Guid="8f9ee1cf-6a8a-4cc7-8d40-47c337dd9ff2">
              <File Id="config.ini" Source="Files/config.ini" KeyPath="yes"/>
            </Component>
          </Directory>
        </Directory>
      </Directory>
      
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="MyProject"/>
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
        <Directory Id="ApplicationDesktopFolder" Name="MyProject"/>
    </Directory>

    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="33776559-768b-4dbb-a924-984146edf8fb">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="MyProject"
                  Description="MyProject"
                  Target="[#MyProject.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="CleanUpStartMenuShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyProject" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="09a53fb1-0447-4849-9bc4-3971f5fdbbad">
        <Shortcut Id="ApplicationDesktopShortcut"
                  Name="MyProject"
                  Description="MyProject"
                  Target="[#MyProject.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="CleanUpDesktopShortCut" Directory="ApplicationDesktopFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyProject" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
    
    <Feature Id="ProductFeature" Title="MyProjectSetup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="config.ini"/>
      <ComponentRef Id="ApplicationShortcut"/>
      <ComponentRef Id="ApplicationShortcutDesktop"/>
    </Feature>

    </Product>
</Wix>
halfer
  • 19,824
  • 17
  • 99
  • 186
Mendes
  • 17,489
  • 35
  • 150
  • 263
  • May be you can find something from here https://stackoverflow.com/questions/10860731/how-to-create-a-directory-in-wix – mhs Jul 10 '17 at 09:28
  • What have you tried? It looks like your code below "Adds a start menu shortcut" defines the usual Program Files folder hierarchy, then shortcuts. – Michael Urman Jul 11 '17 at 12:21

1 Answers1

0

You need add the tag <Directory Id="INSTALLFOLDER"> outside of ProgramFilesFolder