简体   繁体   English

MSI安装程序数据属性

[英]MSI Installer Data Properties

I'm playing around with MSI installation for a large project I'm working on and im intresting to know more about this properties that i see around. 我正在为一个正在从事的大型项目进行MSI安装,我很想知道有关我所看到的此属性的更多信息。

They are things like [TARGETDIR] or anything wrapped in "[PROPERTNAMEHERE]". 它们是[TARGETDIR]之类的东西,或包裹在[[PROPERTNAMEHERE]“中的任何东西。 I'm trying to find out if their is a list of these anywhere? 我正在尝试找出它们是否在任何地方都是这些的列表?

On a side note, is there anyway to access all of these properties from a custom action. 顺便说一句,是否仍然可以通过自定义操作访问所有这些属性。 I've looked in the Context.Parameters collection but not seeing anything in there. 我已经查看了Context.Parameters集合,但在那里什么都没有看到。 I've been passing /name="[TARGETDIR]\\" as CustomActionData to a customaction but this isn't sufficient. 我已经将/ name =“ [TARGETDIR] \\”作为CustomActionData传递给customaction,但这还不够。

Thanks 谢谢

Steve 史蒂夫

Properties are very important to understand when working with MSI based packages. 使用基于MSI的软件包时,了解属性非常重要。 First of all you should know that there are two kind of properties, public properties and private properties . 首先,您应该知道有两种属性,即公共属性私有属性 When working with custom actions you should always use public properties, to avoid their values getting reset when the install process passes from InstallUI Sequence to InstallExecute Sequence. 使用自定义操作时,应始终使用公共属性,以避免在安装过程从InstallUI Sequence传递到InstallExecute Sequence时重置其值。

Also, very important , a custom action cannot get/set properties when running deferred. 同样, 非常重要的是 ,自定义操作无法在延迟运行时获取/设置属性。 Only immediate, ie nondeferred, custom actions can get/set a property value. 只有立即(即非延迟) 自定义操作才能获取/设置属性值。

There is one exception, when running a deferred custom action you can get the value from the special property called " CustomActionData ". 有一个例外,当运行延迟的自定义操作时,您可以从名为“ CustomActionData ”的特殊属性中获取值。

Now, in what regards the custom actions, you can write C++, C# or VBScript custom actions to get/set properties during the installation. 现在,无论如何考虑自定义动作,您都可以编写C ++,C#或VBScript自定义动作来在安装过程中获取/设置属性。

VBScript is not recommended for an official application release , but you can use it for something quick that you need to use inhouse. 不建议在正式的应用程序版本中使用VBScript,但可以将其用于需要内部使用的快速工具。

For C++ custom actions you will get a DLL, from which you can export one or more methods, to call when your custom action is triggered. 对于C ++自定义操作,您将获得一个DLL,从中可以导出一个或多个方法,以在触发您的自定义操作时进行调用。 Please note that the function signature is different from standard DLLs, analyze the example linked carefully. 请注意,功能签名不同于标准DLL,请仔细分析链接的示例。

You can also get a similar DLL writing C# code , if that is more convenient. 如果更方便的话,您也可以获得编写C#代码的类似DLL。

It is very important to make sure you are not trying to run a standard DLL as a custom action , some commercial/free setup authoring tools support that too, but not all. 确保您不要尝试将标准DLL作为自定义操作运行非常重要,某些商业/免费安装创作工具也支持该功能,但并非全部。 If you plan to write a DLL custom action, its better you do it from the beginning using one of the two samples (C++/C#) linked above. 如果您打算编写DLL自定义操作,则最好从一开始就使用上面链接的两个示例(C ++ / C#)之一执行此操作。

Seconds after I posted this I found what I'm looking for in regards to the property list: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx 发布此消息几秒钟后,我发现了我要查找的关于属性列表的内容: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/aa370905(v=vs.85).aspx

Now I'm after a way to access these from code? 现在我正在寻找一种通过代码访问这些内容的方法?

If you are using WIX... 如果您使用的是WIX ...

To answer your side note first - you can access custom values from within a custom action (I'm assuming you know how to set up a custom action...) - look at your session object (parameter to the custom action) - this has a CustomActionData which has an indexer. 首先要回答您的旁注-您可以从自定义操作中访问自定义值(假设您知道如何设置自定义操作...)-查看您的会话对象(自定义操作的参数)-有一个带有索引器的CustomActionData。 Specify the name of the property you want to get out of it by specifying 通过指定来指定要使用的属性的名称

session.CustomActionData["INSTALLLOCATION"]

You need to add the property to your custom action before you can access it however - and to do this you need to tell wix to set this up... 但是,您需要先将该属性添加到自定义操作中,然后才能访问它-为此,您需要告诉wix进行设置...

<CustomAction Id="UNIQUEID" Return="check" Property="YourCustomActionNameInWix" Value="INSTALLLOCATION=[INSTALLLOCATION]" />

To answer your other question - no I don't think you can get these values in code I have always had to script them. 要回答您的另一个问题-不,我认为您无法在必须编写脚本的代码中获得这些值。

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM