使用WiX DTF获取组件代码 [英] Get component code using WiX DTF

查看:91
本文介绍了使用WiX DTF获取组件代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找到一种在给定产品代码的情况下获取Windows Installer组件代码的方法. (我实际上是在尝试使用不包含组件代码的快捷方式获取已安装产品的组件路径,但这是

I have been trying to find a way to get a Windows Installer component code given a product code. (I'm actually trying to get the component path for an installed product using a shortcut that doesn't contain the component code, but this is a longer story.)

我遇到了WiX DTF(Microsoft.Deployment.WindowsInstaller)程序集,这似乎是完成MSI工作的好方法.当我编写以下代码时,我充满了希望:

I have come across the WiX DTF (Microsoft.Deployment.WindowsInstaller) assembly and this looks like a nice way to get MSI stuff done. I was very hopeful when I wrote the following code:

Session product = Installer.OpenProduct(productCode);
ComponentInfoCollection components = product.Components;
ComponentInfo component = components.FirstOrDefault();

我希望我可以从ComponentInfo获得组件代码.不幸的是,我看不到这样做的方法.

I hoped I could get the component code from ComponentInfo. Unfortunately I see no way to do this.

是否可以使用WiX DTF类获取组件代码? (或者其他任何方式...)

Is it possible to get the component code using the WiX DTF classes? (Or any other way come to that...)

推荐答案

我不理解为产品"获得组件"的愿望,因为它不是1:1的关系.也就是说,这可以满足您的要求:

I don't understand the desire to get "the component" for "the product" as it's not a 1:1 relationship. That said this could would do what you ask:

const string PRODUCT_CODE = "{EBBD327E-F220-4567-88F8-CEE3BE560F81}";
var comps = from c in ComponentInstallation.AllComponents
            where c.Product.ProductCode == PRODUCT_CODE
            select c;
string componentId = comps.FirstOrDefault().ComponentCode;

这篇关于使用WiX DTF获取组件代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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