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
Leave a Reply