19
votes

I am using Wix to create an installation for a website.

When adding a font, WiX picks up on the .ttf extension and requires you to install it to the local Font folder (When using a Directory Id="FontsFolder" and TrueType="yes"). If you remove these attributes, it falls over.

Is there a way to get WiX to install the fonts to a custom folder (../Content/fonts/) without complaining?

EDIT:

   <Directory Id="dirFontsFolder" Name="fonts">
       <Component Id="cfont.ttf" Guid="BDEBACC8-D057-4406-87B9-B310BA6DFE27">
           <File Id="font.ttf" Source="$(var.SrcWebsite)\Content\fonts\font.ttf" KeyPath="yes" />
       </Component>
   </Directory>

With the above code, I get the error:

error LGHT1076 : ICE60: The file font.ttf is not a Font, and its version is not a companion file reference. It should have a language specified in the Language column.

4

4 Answers

13
votes

After the issue being raised months later we managed to find the issue:

The KeyPath solution was half of the answer (See Alex's Answer). Without using the KeyPath attribute in WiX, the below solution will not work.

The other part is the Internal Consistency Evaluators (ICE) that WiX runs through Linker (light.exe) when packaging the MSI. The ICE rule ICE07, checks the contents of the files, and if it determines that the file is a font, will force the file in Windows/Fonts.

To stop this happening, you need to disable this rule when light.exe runs. To do this, you add the -sice: parameter after light.exe. For our example it would be:

light.exe -sice:ICE07

You can disable multiple rules by adding more -sice parameters.

5
votes

You can acheive the same thing with VS:

Right Click on the Setup Project, click on Properties.

Select the Tool settings Tab.

In the ICE validation section, you can suppress all warnings, or a specific one ICEXX, in this case

[ICE60]

OR

On the same TAB (Tool Settings), you can add additional parameters to the compiler or the linker. So, in the linker section just add

[-sice:ICE60]

5
votes

For the specific case of bootstrap glyphicons_halflings.ttf font which drops into the fonts folder of the website by design this solution works without supressing ICE07 warnings:

Because you will also be installing the matching woff, eot, and svg webfonts at the same time, you can specify that the TTF file has a companion file and is not a TrueType font.

If you naively just create a WiX fragment to add the Halflings font files to your sites fonts folder like this: (replace the partial GUIDs as needed)

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebsiteFontsDir">
            <Component Id="CMP_WebsiteFonts" Guid="{********-482C-4924-B06E-9FAC34F89D1D}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.eot" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.eot" />
                <File Id="glyphicons_halflings_regular.svg" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.svg" />
                <File Id="glyphicons_halflings_regular.woff" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.woff" />
            </Component>
            <Component Id="CMP_WebsiteFonts2" Guid="{********-BFFE-441D-B8F4-156DD596B09F}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.ttf" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.ttf" DefaultVersion="1.001" TrueType="yes" />
            </Component>
     </DirectoryRef>
</Fragment>

It will add the files to the correct location but building your solution will produce an ICE07 validation warning bemoaning the fact that a TTF font file must go in the Windows Font folder.

Given this is a web font and is not supposed to go there that's very annoying, but thankfully because it is a web font you need it in many formats to appease IE, Edge, Chrome, Firefox, etc... that means you can make use of the presence of the non TTF font variants to eliminate the warning.

Refactor the fragment like this:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebsiteFontsDir">
            <Component Id="CMP_WebsiteFonts" Guid="{********-482C-4924-B06E-9FAC34F89D1D}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.eot" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.eot" />
                <File Id="glyphicons_halflings_regular.svg" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.svg" />
                <File Id="glyphicons_halflings_regular.woff" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.woff" />
            </Component>
            <Component Id="CMP_WebsiteFonts2" Guid="{********-BFFE-441D-B8F4-156DD596B09F}">
                <File Id="glyphicons_halflings_regular.ttf" 
                  Source="$(var.ViewerModule.TargetDir)fonts\glyphicons-halflings-regular.ttf" 
                  TrueType="no" 
                  KeyPath="no"
                  CompanionFile="glyphicons_halflings_regular.eot"/>
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>

Here we deny its a TTF font, and provide it with a companion file that is one of the other web font files. Everything installs where you expect and no ICE07 is produced.

2
votes
<Directory Id="WixWorkshop" Name="WixWorkshop">
  <Component Id="Component1" Guid="DE1705EF-B96A-4746-AA9F-2C9D598E7D08">
    <File Id="File1" Name="arial.ttf" Source="arial.ttf" KeyPath="yes"/>
  </Component>
</Directory>

works well - any component should have reference to directory