MSI:从合并模块 (MSM) 中的自定义操作读取属性

发布于 2024-12-13 12:28:04 字数 555 浏览 0 评论 0原文

我在尝试构建 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怕倦 2024-12-20 12:28:04

事实上,合并模块内的属性可以通过在属性名称后面使用模块 GUID 来访问。

一个好的解决方案是使自定义操作访问 THE_PROPERTY.803A3089_928F_46F1_BBAE_CBD39A7D6A72 而不是 THE_PROPERTY。

另一种解决方案是使用 类型51 自定义操作

  • 在 MSI 中创建一个包含格式化自定义操作的属性集(类型 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:

  • in the MSI create a property set with formatted custom action (type 51)
  • 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文