I'm having a lot of trouble using SourceDir as the target of a shortcut in my WiX script.
I'm now using Wix v4 built under dotnet.
The relevant code is below...
<!-- This property is for the WIX internal usage...
-->
<Property Id="ApplicationFolderName" Value="Mikey\Test" />
<!-- The conversion tool moved the directory structure to the bottom. I don't know why, I think it properly belongs here still
-->
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="Where it will all go via the property above I hope" />
</StandardDirectory>
<StandardDirectory Id="ProgramMenuFolder">
<Directory Id="MikeyStartMenuFolder" Name="Mikey's Stuff for Testing" />
</StandardDirectory>
<?define dExcelFolder1="C:\Users\Mikey\OneDrive\Mikey Excel Add-ins" ?>
<?define dExcelFolder2="[SourceDir]..\..\Mikey Excel Add-ins" ?>
<DirectoryRef Id="MikeyStartMenuFolder">
<Component Id="ShortcutsComponent" Guid="8E967B01-F768-4D2C-9D41-0B5ED11F1849">
<Shortcut Id="MikeyStuffShortcut" Name="Mikeys Stuff Folder" Description="The name is self explanatory"
Target="[APPLICATIONFOLDER]"
WorkingDirectory="APPLICATIONFOLDER" />
<Shortcut Id="MikeyTestShortcut1" Name="Mikeys Test Folder" Description="Test 1"
Target="C:\Users\Mikey\OneDrive\Development Battambang"
WorkingDirectory="APPLICATIONFOLDER" />
<Shortcut Id="MikeyTestShortcut2" Name="Mikeys Test Folder 2" Description="Test 2"
Target="$(var.dExcelFolder1)"
WorkingDirectory="APPLICATIONFOLDER" />
<Shortcut Id="MikeyTestShortcut3" Name="Mikeys Test Folder 3" Description="Test 3"
Target="$(sys.SOURCEFILEDIR)"
WorkingDirectory="APPLICATIONFOLDER" />
<Shortcut Id="MikeyTestShortcut4" Name="Mikeys Test Folder 4" Description="Test 4"
Target="[SourceDir]"
WorkingDirectory="APPLICATIONFOLDER" />
<Shortcut Id="MikeyTestShortcut9" Name="Mikeys Test Folder 9" Description="Test 9"
Target="[APPLICATIONFOLDER]"
WorkingDirectory="APPLICATIONFOLDER" />
<RemoveFolder Id="CleanUpShortCut" Directory="MikeyStartMenuFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Mikey\Stuff" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<!-- I got this off the internet, but it also doesn't get through the compiler. Complains about element text
<InstallUISequence>
<ResolveSource After="CostInitialize"> UPGRADINGPRODUCTCODE OR NOT Installed </ResolveSource>
</InstallUISequence>
-->
<InstallExecuteSequence>
<ResolveSource Before="CostFinalize" Suppress="no" />
</InstallExecuteSequence>
The problem is that MikeyTestShortcut1 through MikeyTestShortcut4 don't get created. Note that MikeyStuffShortcut and MikeyTestShortcut9 do work and get created.
What should I do? I prefer to simply use SourceDir as the Target path. Ultimately though, I'd like to be be able to hardcode a directory also if I might need that too one day.
I'm posting additional information here since I posted the original question. I'm using Sandboxie, a new tool for me that I'm still getting used to.
Going via "Programs", it shows Mikey's Stuff Folder and Mikey Test Shortcut 9.
However, going via "(host) Start Menu", it also shows Mikey's Test Shortcut 4, which is in fact the one that referenced SourceDir.
So it seems that it may be working. I don't understand why Sandboxie is showing different icons against the shortcuts, they all seem to be created equally in the code. But I will keep working on it. I tried to add Sandboxie to the products list to perhaps attract someone that knows, however I wasn't able to.