Reputation: 1965
Consider I have a WiX Setup Library Project named MyLib.wixproj with 2 files that are shared with different installers. This project has the following (simplified) structure:
MyLib.wxs:
<Wix>
<Fragment>
<Feature Id="MySharedFeature" ...>
<ComponentGroupRef Id="MySharedCompGroup" />
</Feature>
<ComponentGroup Id="MySharedCompGroup" Directory="Directory_SharedFiles">
<Component Id="SharedCompA" Guid="*">
<File Id="SharedFileA Source="$(var.Source)fileA.txt" KeyPath="yes" />
</Component>
<Component Id="SharedCompB" Guid="*">
<File Id="SharedFileB Source="$(var.Source)fileB.txt" KeyPath="yes" />
</Component>
</ComponentGroup>
<Directory Id="Directory_SharedFiles" Name="SharedFiles" />
</Fragment>
</Wix>
One of my installers (Setup Project) references the library this way:
Product.wxs:
<Wix>
<Product>
<FeatureRef Id="MySharedFeature" />
</Product>
</Wix>
Directories.wxs:
<Wix>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyApp">
<!-- Here I want to add a reference to Directory_SharedFiles. -->
<Directory Id="OtherFilesNotShared" Name="MoreFiles">
</Directory>
<Directory>
</Directory>
</Directory>
</Fragment>
<Wix>
Inside the INSTALLDIR directory I want to add a DirectoryRef to Directory_SharedFiles
, declared in my shared project. I tried using DirectoryRef but this tag doesn't exist as a child of Directory and it is not clear to me how to use Directory Id="TARGETDIR"
inside the shared project, like this:
MyLib.wxs:
<!-- This code does not compile! -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="Directory_SharedFiles" Name="SharedFiles" />
</Directory>
</Fragment></Wix>
Is there a way to do this?
Upvotes: 0
Views: 5164
Reputation: 8563
Don't nest the DirectoryRef
element under a Directory
element. Put it directly under the Fragment
element. Read more on DirectoryRef.
Build the directory structure in a shared WiX fragment instead of in each product separately.
Upvotes: 1