NetInverse Developers Blog

April 3, 2009
Category: WiX — Tags: , , , — admin @ 9:45 pm

By default WiX installs your application files into a folder under “Program Files”. This is because normally you have a few lines of code like below:

      <Directory Id='TARGETDIR' Name='SourceDir'>
         <Directory Id='ProgramFilesFolder' Name='PFiles'>
            <Directory Id='MyDir' Name='TestProg' LongName='Test Program'>
               <Component Id='MyComponent' Guid='12345678-1234-1234-1234-123456789012'>

The above WiX example deploys your files to %SystemDrive%\Program files\Test Program. However, sometimes you don’t want this behavior and need to install files to an arbitrary folder. To achieve this, you can try these:

  • Don’t worry about TARGETDIR
  • Create a public property (like MYAPPPATH, or INSTALLDIR) to set the new application installation location
  • Add a Directory node with Id=”MYAPPPATH” and Name=”.”. Note: Name=”.” overrides the parent folder
      <Property Id="MYAPPPATH"><![CDATA[c:\mydir\]]></Property>             <!-- New property -->

      <Directory Id='TARGETDIR' Name='SourceDir'>
         <Directory Id='ProgramFilesFolder' Name='PFiles'>
            <Directory Id="MYAPPPATH" Name=".">                             <!-- Overrides the parent folder -->
               <Directory Id='MyDir' Name='TestProg' LongName='Test Program'>
                  <Component Id='MyComponent' Guid='12345678-1234-1234-1234-123456789012'>

Now you can have what you want, enjoy WiXing!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

©2009 NetInverse. All rights reserved. Powered by WordPress