Search code examples
c#.netwixwindows-application-packaging

WIX v4 installer - How to create shortcuts?


I am new to WIX, and trying to use the heatWave package for visual studio to create an installer for my application. I am trying to use Version 4.

I have my basic installer working. But I am having an issue with creating a shortcut on both the start menu and desktop. I am trying to follow the V4 tutorial and documentation, but I have found it very lacking in this department. (what is there is great, but not for this bit).

I have fallen back to trying to use the V3 documentation for the shortcuts, but I cannot get it working. Possibly because im getting the concepts between V3 and v4 muddled up.

In my package.wxs file, I have the following. AppComponents is the content of my ProgramFile directory, and that works. I am trying to get StartMenu, to be the components needed for the start menu shortcut.

  <Feature Id="Main">
      <ComponentGroupRef Id="AppComponents" />
      <ComponentGroupRef Id="StartMenu" />
</Feature>

I then have a file called StartMenu.wsx, and inside it I have the following.

<Fragment>
  <ComponentGroup Id="StartMenu" Directory="?????? what should this be???">

          <Component Id="ApplicationShortcut" Guid="25759f5a-xx-aaa09414394f">
          <Shortcut Id="ApplicationStartMenuShortcut"
                    Name="myApp"
                    Description="foobar"
                    Target="[myapp.exe]"
                    WorkingDirectory="INSTALLFOLDER"/>
          <RemoveFolder Id="CleanUpShortCut" Directory="????" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\MyApp" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
      
  </ComponentGroup>

I do also have my Folders.wxs file that I have tried to use as the directory reference, but no luck in getting it working.

<Directory Id="ProgramMenuFolder">
      <Directory Id="ApplicationProgramsFolder" Name="myApp"/>
</Directory>

The Wix project builds and the installer works, but the shortcut is not apearing on my start menu. I'm using windows 11.

Is there anywhere, where I can find a guide for how to do this for V4, or can you spot what it is i am doing wrong? I'm not really sure how the Directory="" paramater should be used in this scenario, as V3 and 4 seem to differ in this regard.

Any help or pointers much appreciated.


Solution

  • The answer to how i solved this problem, can be found in this youtube video, from @rob mensching above - thankyou.

    In the end, it was very simple. In my AppComponents.wxs file, i had the following:

    <Component>
            <File Source="myApp.exe" />
        </Component>
    

    All i had to do was enter a shortcut under here.

        <Component>
            <File Source="myApp.exe">
                
                <Shortcut Name="MyAppName" Directory="DesktopFolder" 
                          Advertise="yes" WorkingDirectory="INSTALLFOLDER" />
                
                <Shortcut Name="myApp" Directory="ProgramMenuFolder" 
                          Advertise="yes" WorkingDirectory="INSTALLFOLDER" />
            </File>
        </Component>
    

    I hope this helps someone, and look forward to reading the new and updated WIX4 documentation when it arrives.