[wix-users] Preserving recursive directory structure during component copy

Zac Harvey zharvey at pobox.com
Mon Dec 30 12:17:34 PST 2019


Wix 3.11.2 and Visual Studio Community 2019 here. My project has the following directory structure:

...\Source\Repos\my-app-setup\
 my-app-setup\
 bin\
 obj\
 testo\
 fizz\
 abc\
 def\
 ghi\
 abba.txt
 buzz\
 bar.txt
 foo.txt
 my-app.exe
 my-app-setup.wixproj
 my-app-setup.wxs
 my-app-setup.sln


Where the *my-app-setup.wxs* file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
 <Product Id="*" Name="MyApp" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="1e540666-dda2-4cbe-91b7-ac9525d96c86">
 <Package Description="MyApp tool" Compressed="yes" />

 <MediaTemplate EmbedCab="yes"/>

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

 <Directory Id="DesktopFolder" Name="Desktop">
 <Component Id="ApplicationShortcutDesktop" Guid="*">
 <Shortcut Id="ApplicationDesktopShortcut"
 Name="MyApp"
 Description="Shortcut for MyApp"
 Target="[INSTALLFOLDER]my-app.exe"
 WorkingDirectory="INSTALLFOLDER"/>
 <RemoveFolder Id="DesktopFolder" On="uninstall"/>
 <RegistryValue
 Root="HKCU"
 Key="Software/MyApp"
 Name="installed"
 Type="integer"
 Value="1"
 KeyPath="yes"/>
 </Component>
 </Directory>
 </Directory>

 <Component Id="FooTxtComponent" Directory="INSTALLFOLDER">
 <File Source="testo/foo.txt" />
 </Component>

 <Component Id="AbbaComponent" Directory="INSTALLFOLDER">
 <File Source="testo/fizz/abc/def/ghi/abba.txt" />
 </Component>

 <Component Id="ExecutableComponent" Directory="INSTALLFOLDER">
 <File Source="my-app.exe" />
 </Component>

 <Feature Id="MainFeature" Title="MyApp" Level="1">
 <ComponentRef Id="FooTxtComponent" />
 <ComponentRef Id="AbbaComponent" />
 <ComponentRef Id="ExecutableComponent" />

 <ComponentRef Id="ApplicationShortcutDesktop" />
 </Feature>
 </Product>
</Wix>

So it basically just copies a bunch of files from the project into the *C:\Program Files (x86)\MyApp* directory and then creates a shortcut (to the EXE) on the desktop. Simple stuff.

When I build this and run the MSI the resulting *C:\Program Files (x86)\MyApp* directory looks like this:

C:\Program Files (x86)\
 MyApp\
 foo.txt
 abba.txt
 my-app.exe

So WiX is just plucking the files I specified and dropping them into the *MyApp* directory, at the same level as the EXE file. I *don't* want this; I want to preserve the same recursive directory structure as what exists in my VS project. So instead of the above I would like the WiX MSI to generate:

C:\Program Files (x86)\
 MyApp\
 testo\
 fizz\
 abc\
 def\
 ghi\
 abba.txt
 foo.txt
 my-app.exe

*What is the simplest way to accomplish this?*

Thanks!


More information about the wix-users mailing list