I already successfully created an MSI for PyCharm because the installer is not working properly in silent mode. So I had my first successful experience with WiX.
Now, I got a folder to install from our developers. This program should go to "C:\ProgramFiles\Folder A\Folder B" because later there will be another package that goes to "C:\ProgramFiles\Folder A\Folder C"
So, here's what I got (part of it):
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="Folder A"/>
<Directory Id="APPLICATIONSUBDIRECTORY" Name="Folder B"/>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Program B"/>
</Directory>
</Directory>
I am trying now to create the shortcut
<Shortcut Id="ApplicationStartMenuShortcut" Name="Program B" Target="[APPLICATIONSUBDIRECTORY]\Program B.exe" Icon="ProductIcon" WorkingDirectory="APPLICATIONSUBDIRECTORY"/>
So, my intention was that APPLICATIONSUBDIRECTORY = "C:\ProgramFiles\Folder A\Folder B" but it's going to be "C:\ProgramFiles\Folder B"
I found this: Setting Wix shortcut with environment variable workingdirectory
But I would rather not use additional properties if there's already a directory structure.
Leaving away this:
<Directory Id="APPLICATIONSUBDIRECTORY" Name="Folder B"/>
and using APPLICATIONROOTDIRECTORY would work but I need a second layer of folders.
The Target
attribute does not like this as well.
Using (a combination of variables)
Target="[APPLICATIONROOTDIRECTORY]\[APPLICATIONSUBDIRECTORY]\Program B.exe"
does not work but
Target="[APPLICATIONROOTDIRECTORY]\Folder B\Program B.exe"
does.
As I am new to WiX I am still struggling to define directories. The first 2 Directory Ids are joined but the 3rd one doesn't.
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="Folder A"/>
<Directory Id="APPLICATIONSUBDIRECTORY" Name="Folder B"/>
</Directory>
This is my batch file:
@echo off
SET WIXPATH=C:\Program Files (x86)\WiX Toolset v3.11\bin
SET COMPONENTGROUP=MyCompGroup
SET FILEFOLDER=Files
SET FILELIST=FileList
SET MAINFILE=Main
SET MSINAME=Program B.msi
if exist FileList.wxs del FileList.wxs
if exist *.wixobj del *.wixobj
if exist *.wixpdb del *.wixpdb
if exist *.msi del *.msi
if exist *.cab del *.cab
pause
"%wixpath%\heat.exe" dir ".\%FILEFOLDER%" -cg %COMPONENTGROUP% -dr APPLICATIONROOTDIRECTORY -out %FILELIST%.wxs -gg -ke -srd -sfrag -template fragment
"%wixpath%\candle.exe" -arch x86 %MAINFILE%.wxs %FILELIST%.wxs
"%wixpath%\light.exe" -b %FILEFOLDER% -out "%MSINAME%" %MAINFILE%.wixobj %FILELIST%.wixobj
And that's the directory structure to "capture":
/--Files
/----Program B
/------File1
/------File2
etc.