覆盖“文本框” MSI 安装程序中命令行的对话框字段(Visual Studio 2010 Web 安装程序)

发布于 2024-12-15 18:09:35 字数 1059 浏览 3 评论 0原文

背景

我在 Visual Studio 2010 中有一个 Web 安装项目。

用户界面 部分,我有一个自定义文本框 对话框。这些文本字段具有诸如 EDITA1、EDITA2 之类的属性名称。

我有一个使用这些属性的自定义操作

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

在处理此自定义操作的代码中,这些参数可在Context.Parameters字典中找到

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"];

问题

我想要的 能够从脚本运行安装程序,无需 UI,因此我需要通过命令行传入 foobar 的值。您应该执行此操作的方法是将 PROPERTY=VALUE 附加到 MSI 命令行,如下所示:

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

但这不起作用。与自定义文本字段关联的自定义参数确实会显示。例如,BLARB 就可以很好地通过(Parameters["zip"]=="Donut")。但是与文本字段关联的属性不会显示,就好像在调用我的自定义安装函数之前它们被空(但隐藏)对话框删除一样。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

合久必婚 2024-12-22 18:09:35

覆盖属性值的不是对话框。日志文件将帮助您确定导致属性值更改的原因。

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

治碍 2024-12-22 18:09:35

好吧,我遇到了同样的问题,经过大量测试和调试,遵循互联网上的所有建议,发现自己很无助,直到我阅读 此帖子

在Web设置项目中,设置值
EDITA1 值=[变量]。在自定义操作中,自定义数据设置 /va=[EDITA1]

现在,当您通过命令行安装应用程序时,您需要设置 VARIABLE=data
当您运行 GUI 时,在文本框中键入数据。

它有效,我也在日志文件中进行了测试和验证。

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.

海拔太高太耀眼 2024-12-22 18:09:35

问题是生成的 MSI 文件中的 InstallExecuteSequence 具有一些自定义操作,例如 CustomTextA_SetProperty_EDIT1。如果您查看此内容,它实际上会将属性值设置为 null,即使您已在命令行中指定了它。要将它们从命令行静默传递到 MSI,您需要编辑 MSI 文件(例如使用 Orca)以:

  1. 删除 InstallExecuteSequence 表中名称如 CustomTextA_SetProperty_EDIT1 的自定义操作。

  2. 在属性表中的 SecureCustomProperties 值中,添加您的编辑属性,所有属性均用冒号分隔。例如,将“;EDITA1”添加到现有列表中。

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.

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