0

I have this WiX source, which is intended to create a shortcut on the start menu. This is based on the example in the WiX docs at https://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_start_menu_shortcut.html#:~:text=How%20To%3A%20Create%20a%20Shortcut%20on%20the%20Start,3%20Tell%20Windows%20Installer%20to%20install%20the%20shortcut

<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <?include $(sys.CURRENTDIR)\Config.wxi?>
    <Fragment>
        <DirectoryRef Id="dirStartMenuFolder">
            <Component Id="cMyShortcut" Guid="my-guid">
                <Shortcut Id="shMyShortcut"
                        Name="MyApp" 
                        Description="My Great App"
                        Target="[#fMyApp]" WorkingDirectory="dirIniFolder" />
                <RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="InstalledMyShortcut" Type="integer" Value="1" KeyPath="yes" />
                <RemoveFolder Id="rmStartMenuFolder" Directory="dirStartMenuFolder" On="uninstall" />
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>

Candle.exe is OK with this, but Light.exe complains as follows:

D:...\Installer\Directories.wxs(27) : error LGHT0204 : ICE64: The directory dirStartMenuFolder is in the user profile but is not listed in the RemoveFile table.

I'm a bit dumbfounded by that, because the directory has an explicit <RemoveFolder> element.

Any ideas?

Tim Long
  • 13,508
  • 19
  • 79
  • 147

1 Answers1

0

Oh duh, never mind I solved it. It's amazing how the act of posting to SO makes you see the answer immediately. I'm posting the answer rather than deleting the question, because this is a trap that I've fallen into before and I think there might be value in having this pointed out.

The problem is that I wasn't referencing the shortcut component from anywhere, so it was getting optimized away, leaving a dangling directory in Directories.wxs (there's a clue to that in the error message that I failed to spot).

The fix was to reference the component from within my feature tree...

    <FeatureGroup Id="fgRoot">
      <Feature Id="featMyApp" Title="My Application" Level="1" Absent="disallow" Display="expand">
        <ComponentGroupRef Id="cgHtml" />
        <ComponentGroupRef Id="cgImages" />
        <ComponentGroupRef Id="cgMyApp" />
        <ComponentGroupRef Id="cgIniFile" />
        <ComponentRef Id="cMyShortcut" />
      </Feature>
    </FeatureGroup>
Tim Long
  • 13,508
  • 19
  • 79
  • 147