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:
- Skip the shortcut table and write a custom action to handle it yourself.
- Write a custom action to dynamically author the ShortCut table at runtime using SQL TEMPORARY syntax.
- 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.