1

Please, could anyone provide a full .wxs example for creating a MSI package?

I've already read this thread already: How to install Open Type Fonts using Wix

But it does not help me enough. I would add a comment there, but I've got not enough reputation points :/

What is wrong? I receive following errors:

D:\share\IT\install-MSI\MSI věvoj\fonty-2016>candle font-Gabka2.wxs 
Windows Installer XML Toolset Compiler version 3.10.2.2516
Copyright (c) Outercurve Foundation. All rights reserved.

font-Gabka2.wxs
D:\share\IT\install-MSI\MSI věvoj\fonty-2016\font-Gabka2.wxs(14) : warning CNDL1091 : The Package/@Id attribute has been set.  Setting this attribute will allow nonidentical .msi files to have the same package code.  This may be a problem because the package code is the primary identifier used by the installer to search for and validate the correct package for a given installation.  If a package is changed without changing the package code, the installer may not use the newer package if both are still accessible to the installer.  Please remove the Id attribute in order to automatically generate a new package code for each new .msi file.

D:\share\IT\install-MSI\MSI věvoj\fonty-2016>light font-Gabka2.wixobj 
Windows Installer XML Toolset Linker version 3.10.2.2516
Copyright (c) Outercurve Foundation. All rights reserved.

D:\share\IT\install-MSI\MSI věvoj\fonty-2016\font-Gabka2.wxs(34) : error LGHT0094 : Unresolved reference to symbol 'WixAction:InstallExecuteSequence/RemoveExistingProducts' in section 'Product:*'.

The source WXS file code:

<?xml version='1.0'?>
<?define ProductName = "Font Gabka2 (SVČ Lužánky)"?>
<?define PrevProductVersion = "1.0"?> <!-- Match previous version, use "1.0.0" for new install if not known -->
<?define ProductVersion = "1.0"?> <!-- Match new version -->
<?define ProductCode = "PUT-GUID-HERE"?> <!-- Re-generate for new upgrade! (http://www.guidgen.com/) -->
<?define ProductUpgradeCode = "PUT-GUID-HERE"?> <!-- When upgrading, overwrite with previous ProductCode here. -->
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
        <Product Id='*'
                UpgradeCode="$(var.ProductUpgradeCode)"
                Name="$(var.ProductName)"
                Language='1033'
                Version='$(var.ProductVersion)'
                Manufacturer='SVČ Lužánky'>
                <Package Id='$(var.ProductCode)'
                        Description='$(var.ProductName) $(var.ProductVersion)'
                        InstallerVersion='200'
                        Compressed='yes' />
                <Media Id='1' Cabinet='setup.cab' EmbedCab='yes' />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="FontsFolder">
    <Component Id="InstallFonts" Guid="*">  <!-- New GUID HERE FOR NEW FILE (no changes for upgrade, though) -->
      <File Id="Gabka2.ttf" Source="Gabka2.ttf" TrueType="yes" KeyPath="yes" /> 
    </Component> 
  </Directory>  
</Directory> 

                <Upgrade Id="$(var.ProductUpgradeCode)">
                        <UpgradeVersion Minimum="$(var.ProductVersion)"
                                IncludeMinimum="no"
                                OnlyDetect="yes"
                                Language="1033"
                                Property="NEWPRODUCTFOUND" />
                        <UpgradeVersion Minimum="$(var.PrevProductVersion)"
                                IncludeMinimum="yes"
                                Maximum="$(var.ProductVersion)"
                                IncludeMaximum="no"
                                Language="1033"
                                Property="UPGRADEFOUND" />
                </Upgrade>
                <Property Id="ARPSYSTEMCOMPONENT" Value="1" />
                <Feature Id='InstallFeature' Title='Install Feature' Level='1'>
                        <ComponentRef Id='InstallFonts' />
                </Feature>

                <!-- Prevent downgrading -->
                <CustomAction Id="PreventDowngrading" Error="Newer version already installed." />

                <InstallUISequence>
                        <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
                </InstallUISequence>
        </Product>
</Wix>

Thank you

PS: How to install more TTF fonts in one MSI? If I add more files, I get errors like this:

error CNDL0042 : The Component element has multiple key paths set.  The key path may only be set to 'yes' in extension elements that support it or one of the following locations: Component/@KeyPath, File/@KeyPath, RegistryValue/@KeyPath, or ODBCDataSource/@KeyPath.

PS2: I've used this project https://github.com/pennmanor/wix-wrapper as a template base for my new WIX-MSI font project.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
crysman
  • 167
  • 1
  • 11

2 Answers2

2

Some of the things that are wrong:

Don't make the Package Id fixed, use an "*" so you get a new value at every build.

There's no need for custom actions or upgrade elements for your downgrade prevention. Use the majorupgrade element - it seems to have everything you need.

The fonts error message doesn't seem to apply to the source you posted because it refers to multiple files in a component.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Thank you, PhilDW, the proble is, though, that I am not a WIX developer and I am very new to it's XML format and capabilities, so I do not understand fully what does it mean "no need for custom actions or upgrade elements for your downgrade prevention. Use the majorupgrade element" - I would be really glad if somebody could post me here or somewhere functional WIX file for creating a MSI to deploy fonts. There is one site looking like doing so (https://www.hass.de/), but it does not work - the source code contains only part of lines, the majority of source code is missing :/ – crysman Jun 29 '16 at 10:50
  • I've fixed both issues, I'll report here later how, no time now. – crysman Jun 29 '16 at 15:37
1

Here is the solution to this kind of issues:

1) "...error CNDL0042 : The Component element has multiple key..." issue:

just remove the "KeyPath" attributes completely, it works without it

2) multiple fonts: when 1) is done, it is no problem to include more fonts with simple adding more "File" tags into the "Component" subtree. Beware of having unique id's. Example:

<Component Id="InstallFonts" Guid="a028a73b-xxxx-xxxx-xxxx-da4e3e03aef5">  <!-- New GUID HERE FOR NEW FILE (no changes for upgrade, though) -->
  <File Id="Gabka2.ttf" Source="Gabka2.ttf" TrueType="yes" /> 
  <File Id="Gabka2_bold.ttf" Source="Gabka2_bold.ttf" TrueType="yes" /> 
</Component> 

3) "...error LGHT0094 : Unresolved reference to symbol..." issue:

This is fixed by adding:

<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>

just before the end Product tag.

4) encoding/character/code issue ("...error LGHT0311 : A string was provided..."):

Fixed by adding "Codepage" attribute to the main "Product" tag, that is:

<Product Id='*'
    Codepage="utf-8"
    UpgradeCode="$(var.ProductUpgradeCode)"
    Name="$(var.ProductName)"
    Language='1033'
    Version='$(var.ProductVersion)'
...

Hope this helps, #crysman

crysman
  • 167
  • 1
  • 11