1

I'm building a WiX installer for an application, using burn and the WixStandardBootstrapperApplication type. This installer installs .NET 4.6.2, SQL Server, the database schema, and the application. I'm pretty sure that everything but the application works, but I can't test, because I'm getting the following error when building the application MSI:

The File element contains an unhandled extension element 'Shortcut'.  
Please ensure that the extension for elements in the '' namespace has been provided.

Now, everything I've read says I just need to add -ext <DLL for the namespace> to the build command, and everything will work out. Sadly, with no namespace listed, I can't do this.

I generate the MSI in its own project, the details of which are here (sanitized):

I'm generating the list of components through heat.exe in a pre-build event. Here's that command:

"%WIX%bin\heat" dir "APPLICATIONDIR\bin\Release" -gg -cg Application32 -scom -sreg -sfrag -srd -dr INSTALLDIR -var "var.SourceDir" -t ../../Application.xslt -out "..\..\Fragments\Application.wxs"

Product.wxs:

<xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" 
           Name="Installer32" 
           Language="1033" 
           Version="1.0.0.0" 
           Manufacturer="Company Name" 
           UpgradeCode="YOURGUID-12D0-4836-99F0-CB0C14264423">
        <Package InstallerVersion="200" 
             Compressed="yes" 
             InstallScope="perMachine" />
      <Media Id="1"
             Cabinet="Application.cab" />
    <Property Id="DISABLEADVTSHORTCUTS" Value="1" />
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <Feature Id="ProductFeature" 
             Title="Installer32" 
             Level="1">
            <ComponentGroupRef Id="Application32" />
            <ComponentRef Id="ApplicationStartMenuShortcut"/>
        </Feature>
    </Product>
    <Fragment>
    <!-- ProgramFiles directory-->
        <Directory Id="TARGETDIR" 
               Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="CompanyFolder"
                   Name="Company">
                  <Directory Id="INSTALLDIR" 
                      Name="Application">  
          </Directory>
              </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="Product Name" />
      </Directory>
        </Directory>
    </Fragment>
</Wix>

Application.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
                xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                exclude-result-prefixes="wix">
  <xsl:output method="xml" indent="yes" />
  <!-- This modifies the auto-generated Component for the executable to add shortcuts to start menu and desktop -->
  <xsl:template match='wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and (@Id = "filAE9755507C00040964294096392BF6A2")]'>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <Shortcut Id="ApplicationDesktopShortcut"
                Directory="ApplicationProgramsFolder"
                Name="Application" 
                Advertise="yes" />
    </xsl:copy>
  </xsl:template>
  <!-- Identity template: copies everything without change -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

EDIT: Added output of HEAT:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="INSTALLDIR">
            [ SNIPPED MANY ]
            <Component Id="cmpE60EA55C613C91D5119575B9B63102FB" Guid="{7A9A6D6D-960F-4ADB-8DC8-7A09FED71D48}">
                <File Id="filAE9755507C00040964294096392BF6A2" KeyPath="yes" Source="$(var.SourceDir)\Application.exe"><Shortcut Id="ApplicationDesktopShortcut" Directory="ApplicationProgramsFolder" Name="Application" Advertise="yes" xmlns="" /></File>
            </Component>
            <Component Id="cmpA0604D18A00382A0CB4E004C7C2286DA" Guid="{538403B0-09ED-46C7-AD94-403C05ADAB56}">
                <File Id="fil2F48795734FE3514952453321B4758C3" KeyPath="yes" Source="$(var.SourceDir)\Application.exe.config" />
            </Component>
            [ SNIPPED MANY ]
            <Directory Id="dir43A0033346A51A6633F88C79EA143D36" Name="da">
                <Component Id="cmp46F002450D6F653B36DCD369206685B4" Guid="{64EC22D1-B0ED-49E1-979E-7B8F54C558E3}">
                    <File Id="fil85957091B9F72CCAF0CF1D59748A6046" KeyPath="yes" Source="$(var.SourceDir)\da\Product.Utilities.resources.dll" />
                </Component>
            </Directory>
            [ SNIPPED MANY ]
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="Application32">
            [ SNIPPED MANY ]
            <ComponentRef Id="cmpE60EA55C613C91D5119575B9B63102FB" />
            <ComponentRef Id="cmpA0604D18A00382A0CB4E004C7C2286DA" />
            [ SNIPPED MANY ]
            <ComponentRef Id="cmp46F002450D6F653B36DCD369206685B4" />
            [ SNIPPED MANY ]
        </ComponentGroup>
    </Fragment>
</Wix>

The only other SO question that has a blank namespace is this one: Migrating from WiX 3.10 to WiX 4.0: unhandled extension element. The solution in that does not apply to this question, as I'm not using the Registry element, nor am I switching to WiX 4. I may be using another element that's deprecated, I don't believe I am.

Any hints as to the path forward would be appreciated. Thanks.

Community
  • 1
  • 1
  • I ran wixcop on my wxs. It only complained about my code formatting. No decprecated elements. – Bill Fisher May 18 '17 at 18:26
  • 1
    Try adding `xmlns="http://schemas.microsoft.com/wix/2006/wi"` to your `xsl:stylesheet` element to put the `Shortcut` element in the proper namespace. – Daniel Haley May 18 '17 at 18:59
  • Could you also past in the wxs from heat output? – Brian Sutherland May 18 '17 at 19:00
  • I will the xmlns thing. I'll edit into the original question the heat output – Bill Fisher May 18 '17 at 19:13
  • Updated with output of heat...I edited out the 100 or so extra lines. I notice that the tab has xmlns="", which is probably the issue. But that's automatically generated by heat.exe – Bill Fisher May 18 '17 at 19:25
  • @DanielHaley, I see xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" already there. Are you suggesting removing the :wix bit? I'll try that, see what breaks! – Bill Fisher May 18 '17 at 19:26
  • 1
    No, don't remove the wix prefix! Just add an additional `xmlns="http://schemas.microsoft.com/wix/2006/wi"`. The namespace declared with the prefix is to help you match/select elements in the input. The `xmlns="http://schemas.microsoft.com/wix/2006/wi"` (default namespace) will be used in elements you create. – Daniel Haley May 18 '17 at 19:28
  • *"Now, everything I've read says I just need to add -ext to the build command"*... well, did you? The DLL in question is wix.dll. Shortcut is defined in the Microsoft.Tools.WindowsInstallerXml.Serialize namespace in that dll. The serializer code specifies that Shortcut is in that namespace... Didja try it? –  May 18 '17 at 19:47
  • @Will I am pretty sure I did try it. Not guaranteeing it. I will try again. In a meeting right now, so updates will be at least half an hour. – Bill Fisher May 18 '17 at 20:01
  • Side tracked by another build error: 'The "WixAssignCulture" task was not found.' Investigating that. – Bill Fisher May 18 '17 at 20:06
  • http://stackoverflow.com/questions/35132076/cannot-build-wix-project-on-windows-10 –  May 18 '17 at 20:14
  • @Will Yeah, found that. The lovely error message associated with that: "Your system administrator has disabled Windows Features." – Bill Fisher May 18 '17 at 20:22
  • If you've got 2017, you can try adding it via the installer. Hit Modify, then under the Individual components tab, try adding the .NET Framework 3.5 development tools (2nd from the top on that tab) –  May 18 '17 at 20:24
  • Well of course there's no complaint about your wxs. The offending element does not appear there. It is created during the XSLT transform. – John Bollinger May 18 '17 at 20:24
  • 1
    Looks like reinstalling WiX 3.11 and rebooting solved the WixAssignCulture issue. And it looks like I may have solved the xmlns problem with @DanielHaley's suggestion of putting xmlns="...." to the xsl:stylesheet. Will determine after I fix this ICE error. – Bill Fisher May 18 '17 at 20:25
  • Thanks everyone for your help. – Bill Fisher May 18 '17 at 20:33

1 Answers1

1

Try adding xmlns="http://schemas.microsoft.com/wix/2006/wi" to your xsl:stylesheet element to put the Shortcut element in the proper namespace.

It should look like this...

<xsl:stylesheet version="2.0"
  xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  exclude-result-prefixes="wix">
Daniel Haley
  • 51,389
  • 6
  • 69
  • 95