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

Zac Harvey zharvey at pobox.com
Tue Dec 31 05:19:27 PST 2019


Thanks so much Edwin, I think I'm close now, however this method does not seem to like it if there are multiple files with the same name, even if they live in two different subdirectories:

<Directory Id="Jre8Folder" Name="jre8">
 <Directory Id="Jre8LibFolder" Name="lib">
 <Directory Id="Jre8LibSecurityFolder" Name="security">
 <Directory Id="Jre8LibSecurityPolicyFolder" Name="policy">
 <Directory Id="Jre8LibSecurityPolicyLimitedFolder" Name="limited" />
 <Directory Id="Jre8LibSecurityPolicyUnlimitedFolder" Name="unlimited" />
 </Directory>
 </Directory>
 </Directory>
</Directory>

<Component Id="Jre8LibSecurityPolicyUnlimitedLocal_policyJarComponent" Directory="Jre8LibSecurityPolicyUnlimitedFolder">
 <File Source="jre8/lib/security/policy/unlimited/local_policy.jar" />
</Component>
<Component Id="Jre8LibSecurityPolicyUnlimitedUs_export_policyJarComponent" Directory="Jre8LibSecurityPolicyUnlimitedFolder">
 <File Source="jre8/lib/security/policy/unlimited/US_export_policy.jar" />
</Component>
<Component Id="Jre8LibSecurityPolicyLimitedLocal_policyJarComponent" Directory="Jre8LibSecurityPolicyLimitedFolder">
 <File Source="jre8/lib/security/policy/limited/local_policy.jar" />
</Component>
<Component Id="Jre8LibSecurityPolicyLimitedUs_export_policyJarComponent" Directory="Jre8LibSecurityPolicyLimitedFolder">
 <File Source="jre8/lib/security/policy/limited/US_export_policy.jar" />
</Component>

In the above WiX XML, when I build the solution in VS Community 2019, I get the following error:

Severity Code Description Project File Line Suppression State Suppression State
Error Duplicate symbol 'File:local_policy.jar' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique. my-app-setup C:\Users\MyUser\Source\Repos\my-app-setup\my-app-setup\my-app-setup.wxs 313 

So it doesn't like the fact that a file named *local_policy.jar* lives inside two different subdirs (*limited* and *unlimited*)...any idea what the fix is here? (The build *also* complains about the other "duplicate" files such as *US_export_policy.jar* living in multiple subdirs as well; I'm just focusing on *local_policy.jar* as an example here.)

Thanks again so much!

Best,
Zac

On Mon, Dec 30, 2019, at 4:03 PM, Edwin Castro wrote:
> You need to author the entire directory structure and place the files in the desired directory:
> 
> <Directory Id="TARGETDIR" Name="SourceDir">
>  <Directory Id="ProgramFilesFolder">
>  <Directory Id="INSTALLFOLDER" Name="MyApp">
>  <Directory Id="TestoFolder" Name="testo">
>  <Directory Id="FizzFolder" Name="fizz">
>  <Directory Id="AbcFolder" Name="abc">
>  <Directory Id="DefFolder" Name="def">
>  <Directory Id="GhiFolder" Name="ghi" />
>  </Directory>
>  </Directory>
>  </Directory>
>  </Directory>
>  </Directory>
>  </Directory>
> </Directory>
> 
> <Component Id="FooTxtComponent" Directory="TestoFolder">
>  <File Source="testo/foo.txt" />
> </Component>
> 
> <Component Id="AbbaComponent" Directory="GhiFolder">
>  <File Source="testo/fizz/abc/def/ghi/abba.txt" />
> </Component>
> 
> <Component Id="ExecutableComponent" Directory="INSTALLFOLDER">
>  <File Source="my-app.exe" />
> </Component>
> 
> --
> Edwin G. Castro
> 
> 
> On Mon, Dec 30, 2019 at 12:28 PM Zac Harvey via wix-users <wix-users at lists.wixtoolset.org> wrote:
>> 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!
>> 
>>  ____________________________________________________________________
>>  WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list