问题描述
是否可以将WIX中的环境变量转换为属性?
Is there a way to get an environment variable in WIX into a property?
我正在尝试通过以下方式获取USERPROFILE
:
I'm trying to get the USERPROFILE
with:
Property Id="UserFolder" Value="$(env.USERPROFILE)\EdwardsApp\MyFolder"
但这只会拾取安装安装程序的构建计算机的USERPROFILE
.
But this only picks up the USERPROFILE
of the build machine, where the installer is built.
我希望它使用正在安装应用程序的计算机的USERPROFILE
.
I want it to use the USERPROFILE
of the machine where the app is being installed.
推荐答案
您可以在安装过程中使用环境变量,但这需要使用自定义操作.您将需要使用UserFolder属性. > Type 51 Custom Action
,而不是在构建过程中设置属性. [%ENVVARNAME]格式用于使用环境变量,但是环境变量的名称区分大小写.
You can make use of Environment variables during installation but this requires using a custom action. You will need to set the UserFolder
property with a Type 51 Custom Action
as opposed to setting the property during the build. The [%ENVVARNAME] format is used to make use of an environment variable, but the name of the environment variable is case-sensitive.
设置属性的自定义操作的WiX示例:
A WiX example of a custom action that sets a property:
<CustomAction Id="SetUserFolder" Property="UserFolder" Value="[%USERPROFILE]EdwardsApp\MyFolder" />
您可以在此处阅读有关WiX中自定义操作的更多信息:
You can read more on Custom Actions in WiX here:
http://blogs.technet.com/b/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspx
这篇关于将环境变量放入WIX属性中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!