(WiX) Program files shortcut for per-machine install

后端 未结 2 1866
野性不改
野性不改 2020-12-15 18:10

Following the example here, I added a shortcut to the ProgramMenuFolder that launches my application. (My code is actually simpler because I don\'t need the extra folder.)<

相关标签:
2条回答
  • 2020-12-15 18:25

    That style of shortcut is for a target that might not be installed now nor at the time it is invoked. It creates the classic .lnk shortcut file. It is useful for shortcuts to targets that your installer is not responsible for but might be useful for users of your product to use (e.g. cmd.exe).

    Alternatively, a shortcut for a target you are installing or advertising will be uninstalled when the target is unadvertised (product is uninstalled). For example, WiX installs a shortcut to wix.chm called WiX Documentation. The Shortcut element for an advertised shortcut can be made a child of the File element.

    Here is a hand-written example:

    <Component Id="ProductComponent">
       <File Source="$(var.ConsoleApplication1.TargetPath)" KeyPath="yes">
         <Shortcut Id="$(var.ConsoleApplication1.TargetName)Shortcut" 
                   Name="$(var.ConsoleApplication1.TargetName)" 
                   Advertise="yes"
                   Description="Starts $(var.ConsoleApplication1.TargetName)"
                   Directory="ProgramMenuFolder" />
       </File>
    </Component>
    

    To insert the Shortcut element into heat's output, pass it the path to an XSL transform. Snippet:

    <xsl:template match="wix:File[contains(@Source,'\myapp.exe')]">
      <xsl:copy-of select="." />
      <Shortcut Id='StartMenuShortcut'
              Advertise="yes"
              Name='$(var.ProductName)'
              Icon='MainIcon.ico'
              Description='$(var.ProductName)'
              WorkingDirectory='ClientDir'/>
    </xsl:template>
    
    0 讨论(0)
  • 2020-12-15 18:35

    What I would recommend doing is simply making the folder as you said, but not placing the shortcut directly under it. Instead make a shortcut element under the component holding the file. You can use the Directory attribute to specify where you want the shortcut to appear.

    0 讨论(0)
提交回复
热议问题