Setting Wix shortcut with environment variable workingdirectory

时间秒杀一切 提交于 2020-02-05 04:42:07

问题


I'm trying to create a shortcut in WIX with teh following WorkingDirectory:

<Shortcut Id="PowerShellShortcut" Name="$(var.PRODUCTNAME) Powershell Prompt" Description="$(var.PRODUCTNAME) Powershell Prompt" WorkingDirectory="%HOMEDRIVE%%HOMEPATH%" Target="[POWERSHELLEXE]" Arguments='-noexit -command "Import-Module [APPLICATIONFOLDER]Binaries\MA.dll | Out-Null"' />

When I try to build I get the following error:

Error 1 The Shortcut/@WorkingDirectory attribute's value, '%HOMEDRIVE%%HOMEPATH%', is not a legal identifier. Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.). Every identifier must begin with either a letter or an underscore.

Is there a workaround to set the literal string "%HOMEDRIVE%%HOMEPATH%" as the WorkingDirectory of a Shortcut?


回答1:


You cannot use environment variables like %HOMEDRIVE% in .wxs files. Instead of %HOMEDRIVE%%HOMEPATH%, try using $(env.HOMEDRIVE)$(env.HOMEPATH)




回答2:


Per the documentation on the Shortcut Table, the working directory (WkDir) stores the name of a property that has the value you want stored into the shortcut. This property may be a DirProperty (i.e. also a reference into the Directory Table), or it may just hold a hardcoded string itself. If you want the final shortcut to have the literal text %HOMEDRIVE%%HOMEPATH%, then set your working directory to something like WKDIR_HOME which is the name of a property you have set to %HOMEDRIVE%%HOMEPATH%.



来源:https://stackoverflow.com/questions/13079965/setting-wix-shortcut-with-environment-variable-workingdirectory

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