1

I am trying to install some fonts that are common to several of our applications, so it seems like putting them in a single shared merge module is the way to go. But I can't get the precise Wix syntax. Here is what I have in the my merge module config file:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Module Id="TS3DFontsMerge" Language="1033" Version="1.0.0.0">
    <Package Id="F6029400-FD05-4213-A0B2-1755387595BF" Manufacturer="Tech Soft 3D" InstallerVersion="200" />
    <DirectoryRef Id="FontsFolder">
          <Component Id="TechSoft3DFonts" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5">
              <File Id="ts3d.ttf" Source="..\..\..\samples\fonts\ts3d.ttf" TrueType="yes" />
              <File Id="MyriadCAD.otf" Source="..\..\..\samples\fonts\MyriadCAD.otf" TrueType="yes" />
      </Component>
    </DirectoryRef>
  </Module>
</Wix>

I'm following the model described here. In this case, I get this error:

ts3d_fonts_merge.wxs(5,0): error CNDL0205: The Directory with Id 'FontsFolder' is not a valid root directory. There may only be a single root directory per product or module and its Id attribute value must be 'TARGETDIR' and its Name attribute value must be 'SourceDir'. ts3d_fonts_merge.wxs(5,0): error CNDL0025: The Directory element requires the Name attribute because there is no parent Directory element.

So my get-to-the-point question is: How can I get Wix to recognize the FontsFolder predefined ID in a merge module? I am using WixToolset v3.10.

Here are a couple other things I tried...

When I had this directly in the main product installer, I had to use the <directory> tag instead of <DirectoryRef>, and that worked. But when I use that in the merge module, I get this error message:

ts3d_fonts_merge.wxs(5,0): error LGHT0094: Unresolved reference to symbol 'Directory:FontsFolder' in section 'Module:TS3DFontsMerge'.

And if I wrap the FontsFolder in a TARGETDIR tag (as was suggested by the first error?), I get warnings that the fonts are being installed to the wrong place. Here is the error message:

light.exe(0,0): warning LGHT1076: ICE07: 'ts3d.ttf.F6029400_FD05_4213_A0B2_1755387595BF' is a Font and must be installed to the FontsFolder. Current Install Directory: 'FontsFolder.F6029400_FD05_4213_A0B2_1755387595BF' light.exe(0,0): warning LGHT1076: ICE07: 'MyriadCAD.otf.F6029400_FD05_4213_A0B2_1755387595BF' is a Font and must be installed to the FontsFolder. Current Install Directory: 'FontsFolder.F6029400_FD05_4213_A0B2_1755387595BF'

Any ideas?

Community
  • 1
  • 1
Ryan Clark
  • 31
  • 4

2 Answers2

2

A couple of quick suggestions:

  • The FontsFolder is a property that will be auto filled for you so make sure to use the <Directory> not <DirectoryRef> - https://msdn.microsoft.com/en-us/library/aa368605(v=vs.85).aspx
  • Just like you learned, any module needs to have a single overall Directory
  • The link you gave I feel has the answer you are looking for but is not the one that was checked...try this suggestion: https://stackoverflow.com/a/33290209
  • To save you troubles later on with file management you may want to have each file be inside it's own component.

So in the end, you should be close to:

?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Module Id="TS3DFontsMerge" Language="1033" Version="1.0.0.0">
    <Package Id="F6029400-FD05-4213-A0B2-1755387595BF" Manufacturer="Tech Soft 3D" InstallerVersion="200" />
    <Directory Id="TARGETDIR">
      <Directory Id="FontsFolder">
            <Component Id="TechSoft3DFonts" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5">
                <File Id="ts3d.ttf" Source="..\..\..\samples\fonts\ts3d.ttf" TrueType="yes" />
                </Component>
                <Component Id="TechSoft3DFonts2" Guid="0B9C43FC-3735-42DE-80F6-1DB2A912BEE5">
                <File Id="MyriadCAD.otf" Source="..\..\..\samples\fonts\MyriadCAD.otf" TrueType="yes" />
        </Component>
      </Directory>
    </Directory>
  </Module>
</Wix>
Community
  • 1
  • 1
ProjectNapalm
  • 353
  • 1
  • 3
  • 9
1

I had the same problem, but I didn't get the whole solution from the previous answer.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

  <Product (...)>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="FontsFolder" />
    </Directory>

    <DirectoryRef Id="FontsFolder">
      <Component Id="MyFont" Guid="0B9C43FC-3735-42DE-80F6-1DB2A912BEE5">
        <File Id="MyFont.otf" Source="Fonts\MyFont.otf" TrueType="yes" />
      </Component>
      <Component Id="MySecondFont" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5">
          <File Id="MySecondFont.otf" Source="Fonts\MySecondFont.otf" TrueType="yes" />
        </Component>
    </DirectoryRef>

    <Feature Id="FontsInstallation" Title="Install and Register Company Fonts" Level="1">
      <ComponentRef Id="MyFont"/>
      <ComponentRef Id="MySecondFont"/>
    </Feature>
  </Product> 
</Wix>

The font is not visible in Paint or Word, but I can reference it with XAML/WPF code by their original names (as they would be installed in Windows):

<TextBlock FontFamily="My First Font" FontSize="30">Sample text</TextBlock>
<TextBlock FontFamily="My Second Font" FontSize="30">Sample text</TextBlock>

Font files are set as Build Action Content and Copy to Output Directory DoNotCopy.

Michał J. Gąsior
  • 1,457
  • 3
  • 21
  • 39
  • 1
    The previous answer and the question is talking about modules which are parts to an installer. Using a module allows anyone to add the same part to different installers and get the same GUIDs and results. The code you have above does work to place the fonts into the fonts folder, but it is a product creating a single installer that cannot be shared with other installations. Though your solution does show how to use DirectoryRef correctly for an installer and solving the issue correctly for a single install. Nicely done! – ProjectNapalm Aug 10 '16 at 19:29