MSI:从合并模块 (MSM) 中的自定义操作读取属性
我在尝试构建 MSM 时遇到了这个问题。显然,模块属性(以及与此相关的所有标识符)在模块生成期间通过在其名称末尾添加模块 GUID 进行重命名。例如,属性“MY_PROPERTY”重命名为“MY_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72”(假设 803A3089-928F-46F1-BBAE-CBD39A7D6A72 是模块 GUID)。我相信这是用于防止尝试使用具有相同名称的标识符的多个模块之间发生冲突的机制。
我需要从 MSM 中调用一个 DLL 自定义操作,该操作需要使用某个值设置特定属性(我们将其称为“THE_PROPERTY”)。问题是 THE_PROPERTY 按照上面的说明重命名为 THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72,因此自定义操作永远找不到该属性并失败。
有什么办法可以解决这个问题吗?我正在考虑修改自定义操作,以便它尝试(以某种方式)找出调用它的模块的 GUID。执行此操作的一种方法是查看当前操作名称,该名称还应包含 GUID。但是我可以从自定义操作中获取当前操作名称吗?你能想到另一个解决方案吗?
谢谢!
I ran into this problem when trying to build an MSM. Apparently module properties (and all the identifiers for that matter) get renamed during the module generation by adding the module GUID at the end of its name. For example, property "MY_PROPERTY" gets renamed to "MY_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72" (assuming 803A3089-928F-46F1-BBAE-CBD39A7D6A72 is the module GUID). I believe this is the mechanism used to prevent conflicts between multiple modules trying to use identifiers with the same name.
From within the MSM I need to invoke a DLL custom action that requires a specific property to be set with some value (let's call it "THE_PROPERTY"). The problem is that THE_PROPERTY gets renamed as explained above to THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72, thus the custom action never finds the property and fails.
Is there any way to solve this problem? I was thinking of modifying the custom action so that it tries to figure out (somehow) the GUID of the module from which it is being invoked. One way of doing this could be by looking at the current action name, which should also include the GUID. But can I get the current action name from within the custom action? Can you think of another solution?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,合并模块内的属性可以通过在属性名称后面使用模块 GUID 来访问。
一个好的解决方案是使自定义操作访问 THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72 而不是 THE_PROPERTY。
另一种解决方案是使用 类型51 自定义操作:
将其配置为将 THE_PROPERTY 设置为:
[THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72]
将其安排在自定义操作之前: THE_PROPERTY
这样,合并模块属性将保存到 MSI 属性中,该属性具有自定义操作所使用的名称。
为每个设置创作工具添加不同的类型 51 自定义操作。如果您需要确切的说明,请提及您正在使用的设置工具。 Visual Studio 不支持此功能。
Indeed, properties inside a merge module are accessed by using the module GUID after the property name.
A good solution is to make the custom action access THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72 instead of THE_PROPERTY.
Another solution is to use a type 51 custom action:
configure it to set THE_PROPERTY to:
[THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72]
schedule it before the custom action which reads THE_PROPERTY
This way the merge module property is saved into an MSI property which has the name used by your custom action.
Type 51 custom actions are added differently for each setup authoring tool. If you need exact instructions, please mention the setup tool you are using. Visual Studio doesn't support this.