WiX Shortcut Points to the Wrong File

I ran into an interesting bug/feature/problem with my WiX 3.0 / Votive installer recently where shortcuts were pointing to the wrong file.  For example in the case of Dubbelbock TFS, I set up a shortcut to Dubbelbock.UI.exe from Startup and from "Benjamin Day Consulting, Inc" in the Programs menu.  What was happening was that rather than starting up Dubbelbock.UI.exe when I logged into my machine, I got Dubbelbock.UI.exe.config popping up in notepad.  (Not exactly what I wanted.)

Here's some sample WiX that has the same problem:

<Component Id="ProductComponent" Guid="05459650-55cc-4abf-9c6a-f836dc0caef8">
    <File
        Id="ClipboardUtility.exe.config"
        Name="ClipboardUtility.exe.config"
        Vital="yes"
        Source="$(var.ClipboardUtility.TargetDir)\ClipboardUtility.exe.config" />
    <File Id="ClipboardUtility.exe"
          Name="ClipboardUtility.exe" Vital="yes"
          Source="$(var.ClipboardUtility.TargetDir)\ClipboardUtility.exe" >
        <Shortcut
            Id="startmenuClipboardUtil"
            Directory="ProgramMenuDir"
            Name="Clipboard Utility"
            WorkingDirectory="INSTALLDIR"
            Icon="ClipboardUtilityIcon.ico" Advertise="yes" />
        <Shortcut
            Id="autostartClipboardUtil"
            Directory="StartupFolder"
            Name="Clipboard Utility"
            WorkingDirectory="INSTALLDIR"
            Icon="ClipboardUtilityIcon.ico"  Advertise="yes" />
    </File>
    <File Id="ClipboardUtilityIcon" Name="C.ico" DiskId="1"
        Source="$(var.ClipboardUtility.ProjectDir)\C.ico" Vital="yes" />
</Component>

Looking at that code, the <shortcut> elements are contained inside of the <file></file> element for ClipboardUtility.exe so you'd think that it would create two shortcuts to ClipboardUtility.exe.  Nope.  It creates two shortcuts to "ClipboardUtility.exe.config".

After playing around with it for a while, I figured out that the <Shortcut> directives will always create shortcuts to the first <File> in the <Component> rather than the <File> that contains the <Shortcut>.

So...the moral of the story is always put your <File>'s with <Shortcut>'s first in your <Component>.

<Component Id="ProductComponent" Guid="05459650-55cc-4abf-9c6a-f836dc0caef8">
    <File Id="ClipboardUtility.exe"
        Name="ClipboardUtility.exe" Vital="yes"
        Source="$(var.ClipboardUtility.TargetDir)\ClipboardUtility.exe" >
          <Shortcut
            Id="startmenuClipboardUtil"
            Directory="ProgramMenuDir"
            Name="Clipboard Utility"
            WorkingDirectory="INSTALLDIR"
            Icon="ClipboardUtilityIcon.ico" Advertise="yes" />
          <Shortcut
            Id="autostartClipboardUtil"
            Directory="StartupFolder"
            Name="Clipboard Utility"
            WorkingDirectory="INSTALLDIR"
            Icon="ClipboardUtilityIcon.ico"  Advertise="yes" />
    </File>
    <File
      Id="ClipboardUtility.exe.config"
      Name="ClipboardUtility.exe.config"
      Vital="yes"
      Source="$(var.ClipboardUtility.TargetDir)\ClipboardUtility.exe.config" />
    <File Id="ClipboardUtilityIcon" Name="C.ico" DiskId="1"
      Source="$(var.ClipboardUtility.ProjectDir)\C.ico" Vital="yes" />
</Component>

-Ben

posted @ Thursday, August 09, 2007 7:11 AM

Print

Comments on this entry:

# re: WiX Shortcut Points to the Wrong File

Left by Nelson Pinto at 9/4/2007 5:29 PM
Gravatar
I faced similar issue.
In my case I had two <FILE> directives in same <COMPONENT> each containing a <SHORTCUT> directive.

But 2nd shortcut always pointed to first file.
I had to split them up into two components to get it working see working solution below.

<Component Id="COMP_MOSTool.exe" Guid="5f61b48e-113d-4b19-a0da-a7f5cb8330fc" DiskId="1">
<File LongName="MOSTool.exe" src="MOSTool.exe" Name="MOSTool.exe" Checksum="yes" Id="FILE_MOSTool.exe" Vital="yes">
<Shortcut Id="MOSTool.exe.lnk" Name="MOSTool.lnk" LongName="MOS ZOOM Tool.lnk" Directory="ProgramMenuFolder" Icon="$(var.RoundTableIcon)" Advertise="yes" />

</File>
</Component>

<Component Id="COMP_SatMicMOSTool.exe" Guid="204b16ff-35e9-4295-9cf8-b95d2c60673d" DiskId="1">
<File LongName="SatMicMOSTool.exe" src="SatMicMOSTool.exe" Name="SatMic.exe" Checksum="yes" Id="FILE_SatMicMOSTool.exe" Vital="yes">
<Shortcut Id="SatMicMOSTool.exe.lnk" Name="SatMic.lnk" LongName="SatMic MOS Tool.lnk" Directory="ProgramMenuFolder" Icon="$(var.RoundTableIcon)" Advertise="yes" />

</File>
</Component>

- Nelson

# re: WiX Shortcut Points to the Wrong File

Left by Riyaz at 4/24/2008 3:40 PM
Gravatar
I've had the same problem in my work, but as I have lots of files to be copied (near 7000) and also more than 1 shortcut, I think we must find another solution. This problem exists in WiX 3, and the WiX 2 Worked correct. What may be the cause?

# Free jenna jameson videos.

Left by Jenna jameson. at 10/10/2008 11:42 AM
Gravatar
Jenna jameson. Jenna jameson hardcore. Jenna jameson movies.

# re: WiX Shortcut Points to the Wrong File

Left by Anna at 3/31/2009 3:50 PM
Gravatar
it's not really the first file in the component that it points to. Instead, it's the "KeyPath" element in the component. Which could be a file, a folder, a registry, a service etc.. If none of the elements in the component is marked with "keypath="yes"", it'll choose the 1st one to be such. And any shortcut is meant to point to the keypath. This looks ugly for those who were used to push hundreds of files under the same component in Wix 2.0, but it looks perfectly right with wix 3.0 philosophy- one INSTALLATION UNIT per one component. Violating of this rule leads to extreme problems, especially when upgrading the product.

# re: WiX Shortcut Points to the Wrong File

Left by Henry at 4/6/2009 3:03 PM
Gravatar
Ben, Anna,
Thanks for the help. I've been fighting with this for 2 hours and couldn't figure out why it wouldn't post to the right file. This worked!!

Thanks!!

Your comment:



 (will not be displayed)


 
 
 
Please add 4 and 7 and type the answer here:
 

Live Comment Preview:

 
«March»
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910