获取生成的 ProductCode 作为 Wix 中的变量 [英] Obtaining generated ProductCode as a variable in Wix

查看:22
本文介绍了获取生成的 ProductCode 作为 Wix 中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的产品中,我们在 Wix 中使用 Product Id="*" 来告诉它为每个新版本生成一个新的产品代码.我们现在需要在安装期间将 MSI 的产品代码记录到我们的注册表项之一中.我们可以通过在卸载"注册表项中循环查找我们的产品名称和版本来在运行时推断产品代码,但在安装时直接记录此信息会更清晰.

In our product we use Product Id="*" in Wix to tell it to generate a new product code for every new build. We now have a requirement during install time to record the product code of the MSI being installed into one of our registry keys. We could infer the product code at runtime by looping through entries in the "Uninstall" registry keys looking for our product name and version, but it would be cleaner to directly record this information at install time.

Wix 有没有办法告诉我它生成了什么 ProductCode,以便我可以将它作为变量添加到 RegistryValue Wix 元素?

Is there a way for Wix to tell me what ProductCode it has generated so that I can add it as a variable to a RegistryValue Wix element?

我猜没有,所以我尝试使用 <?define?> 将变量设置为所有问号 "????????-??????-??????-????-????????????" 并在 Product 元素中使用此变量作为以及 RegistryValue 元素.这对 Product 元素有效,它继续生成新的 GUID,但在 RegistryValue 元素中,此变量在编译时未扩展,这意味着注册表项只是获取添加了所有问号.

I'm guessing there isn't, so I tried using a <?define?> to set a variable to all question marks "????????-????-????-????-????????????" and used this variable in the Product element as well as the RegistryValue element. This works for the Product element ok, it continues to generate a new GUID, but in the RegistryValue element this variable is not expanded at compile time, meaning the registry key simply gets added with all question marks.

是否有任何纯粹的 Wix 方式来实现我想要的?我可以在 Wix 之外生成 ProductCode 并让 Wix 元素将其用作环境变量,但这会增加构建过程的额外复杂性 - 其他可能会破坏的东西.如果我可以纯粹用 Wix 做到这一点,我会很高兴.

Is there any pure Wix way to achieve what I want? I could generate the ProductCode outside of Wix and have the Wix elements use this as an environment variable, but this adds an extra level of complexity to the build process - something else that could break. I would like it if I could do this purely with Wix.

推荐答案

无论您在 @ProductCode 中放入什么,产品代码始终可用作属性.因此,以下内容应该适用于您的情况:

The product code is always available as a property, no matter what you put into the @ProductCode. So, the following should work for your case:

<RegistryKey Root="HKLM" Key="My Product">
   <RegistryValue Name="TheProductCode" Type="string" Value="[ProductCode]" KeyPath="yes" />
</RegistryKey>

此外,它不仅可以放在注册表值中,还可以放在注册表项名称中:

Besides, it can be put not only in the registry value, but the registry key name:

<RegistryKey Root="HKLM" Key="$(var.RegistryRoot)\[ProductCode]">
   ...
</RegistryKey>

这篇关于获取生成的 ProductCode 作为 Wix 中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆