Overriding “Textboxes” dialog fields from the command line in MSI installer (Visual Studio 2010 Web Setup)

纵然是瞬间 提交于 2019-12-04 05:29:36

问题


Background

I have a Web Setup project in Visual Studio 2010.

In the User Interface section, I have a custom Textboxes dialog. These text fields have property names like EDITA1, EDITA2.

I have a Custom Action which makes use of these properties:

CustomActionData = /foo="[EDITA1]" /bar="[EDITA2]" /zip="[BLARB]"

In the code for handling this custom action, these parameters are available in the Context.Parameters dictionary

public override void Install(System.Collections.IDictionary stateSaver) {
    string foo = Context.Parameters["foo"]; // originates in edit box EDITA1
    string bar = Context.Parameters["bar"]; // originates in edit box EDITA2
    string zip = Context.Parameters["zip"];

Problem

I want to be able to run the installer from a script, without a UI, so I need to pass in values for foo and bar via the command line. The way you're supposed to do this is by appending PROPERTY=VALUE to your MSI command line, like this:

msiexec /qn /i MyInstaller.msi EDITA1=John EDITA2=Smith BLARB=Donut

But this doesn't work. Custom parameters which aren't associated with custom text fields do show up. For instance, BLARB gets passed through just fine (Parameters["zip"]=="Donut"). But properties which are associated with the text fields do not show up, as if they are being nuked by the empty (but hidden) dialog box before my custom install function is called.


回答1:


It is not the dialog which overrides the property values. A log file will help you determining what causes the property value change.




回答2:


Well i ran into the same issues and after lot testing and debugging following all the advise on the internet, found myself helpless till i got to read this post.

In the web setup project, set the value of EDITA1 Value=[VARIABLE]. In custom action , customdata set /va=[EDITA1]

Now when you install the application through command line you need to set VARIABLE=data. When you run into the GUI, type the data in the textbox.

It works, i have tested and verified in the log file as well.




回答3:


The issue is that the InstallExecuteSequence in the generated MSI file has some custom actions such as CustomTextA_SetProperty_EDIT1. If you look at this, it does in fact set the property value to null, even if you had specified it on the command line. To pass them from the command line into the MSI silently you'd need to edit the MSI file (for example with Orca) to:

  1. Delete the custom actions in the InstallExecuteSequence table with names like CustomTextA_SetProperty_EDIT1.

  2. In the Property table, the SecureCustomProperties value, add your edit properties all separated by colons. For example add ";EDITA1" to the existing list.



来源:https://stackoverflow.com/questions/8143984/overriding-textboxes-dialog-fields-from-the-command-line-in-msi-installer-vis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!