将环境变量获取到 WIX 属性中 [英] Get an environment variable into a WIX property
问题描述
有没有办法将 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)EdwardsAppMyFolder"
但这只会获取构建机器的 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 属性rel="noreferrer">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]EdwardsAppMyFolder" />
您可以在此处阅读有关 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 属性中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!