Dynamically assigning name to shortcut at run time in WIX

时光总嘲笑我的痴心妄想 提交于 2019-12-06 10:44:38

问题


I want to assign different names to a shortcut based on user input. Is this feasible using the WiX toolset? I have tried assigning value of property to Name attribute of Shortcut element but it does not work.


回答1:


The Name column of the Shortcut Table isn't of type Formatted therefore it isn't possible to use [PROPERTY] to mutate it at runtime.

The only ways I know how to do it are:

  1. Skip the shortcut table and write a custom action to handle it yourself.
  2. Write a custom action to dynamically author the ShortCut table at runtime using SQL TEMPORARY syntax.
  3. There might be an extension out there that has implemented #2.



回答2:


I use this workaround:

<CustomAction Id="SetShortcutFolder" Return="check" Property="ProgramMenuDir" Value="[ProgramMenuFolder][PRODUCTNAME]"></CustomAction>

<!--Setting up the shortcuts for the product-->
    <Directory Id="ProgramMenuFolder" Name="Programs">
       <Directory Id="ProgramMenuDir" Name="TempName"/>
    </Directory>



<!--Set the install path to match the path of the product already installed-->
<Custom Action="SetInstallPath" Before="CostFinalize"/>

Hope this helps..:)




回答3:


If you are doing lots of translations and say lots of permutations, then this is a real drawback. Instead of using WIX (which is one of the most obfuscated API's I've ever used) you may prefer to simply write the shortcut using the Windows API.



来源:https://stackoverflow.com/questions/16524114/dynamically-assigning-name-to-shortcut-at-run-time-in-wix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!