Why Icon element require Id attribute to end with '.exe' or '.ico'

icons, windows-installer, wix

Solution

Looks like it's because of this: http://msdn.microsoft.com/en-us/library/aa369210.aspx (see the remarks section).

I'm guessing it's failing validation because `Icon="ProgramIcon"` does not match the extension of the shortcut.

http://wix.sourceforge.net/manual-wix2/wix_xsd_shortcut.htm says

Identifier reference to Icon element. The Icon identifier should have the same extension as the file that it points at. For example, a shortcut to an executable (e.g. "my.exe") should reference an Icon with identifier like "MyIcon.exe"

Problem

Why Icon for Shortcut element should have Id attribute ending with '.ico' or '.exe'? So this code ``` <Icon Id="ProgramIcon" SourceFile="Images\MyAppIcon.ico"/> <Component Guid="MY_GUID" Id="MyAppComponent"> <File Source="MyApp.exe" Name="MyApp.exe" Id="MyApp.exe"> <Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon" Advertise="yes" /> </File> </Component> ``` generates compile error: ``` error LGHT0204: ICE50: The extension of Icon 'ProgramIcon' for Shortcut 'MyApp.Shortcut' does not match the extension of the Key File for component 'MyAppComponent'. [D:\APPS\MyProject.wixproj] ``` but this code ``` <Icon Id="ProgramIcon.ico" SourceFile="Images\MyAppIcon.ico"/> <Component Guid="MY_GUID" Id="MyAppComponent"> <File Source="MyApp.exe" Name="MyApp.exe" Id="MyApp.exe"> <Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" /> </File> </Component> ``` compiles fine. It's first time I see such limitations for Id attribute of any element and it looks very strange. I don't see any reason for this even to be a warning. So I don't understand some basics of this functionality. Please help me understand the reasons of described behavior.

Original source