如何从.Net Installer类自定义操作中查找ProductCode
时间:2020-03-05 18:52:53 来源:igfitidea点击:
我需要在Installer.OnCommitted回调中知道应用程序的ProductCode。似乎没有确定这一点的明显方法。
解决方案
回答
MSI函数MsiGetProperty可用于获取ProductCode属性的名称。我不知道在这种情况下是否可行,因为我从未创建过.NET安装程序。
回答
我最终使用Visual Studio中的CustomActionData属性将产品代码作为命令行参数传递给Installer类(例如/ productcode = {31E1145F-B833-47c6-8C80-A55F306B8A6C}。
然后,我可以使用Context.Parameters StringDictionary从Installer类中的任何回调中访问它。
string productCode = (string)Context.Parameters["productcode"];
回答
我们可以避免在CustomActionData属性中使用/ productCode = [ProductCode]对产品代码进行硬编码。