Skip to content

Make htmlInstaller use edit control values, not contents.#14

Merged
dblock merged 4 commits into
dotnetinstaller:masterfrom
jennings:text-value
Jun 19, 2012
Merged

Make htmlInstaller use edit control values, not contents.#14
dblock merged 4 commits into
dotnetinstaller:masterfrom
jennings:text-value

Conversation

@jennings

Copy link
Copy Markdown
Contributor

(This is an issue from CodePlex, issue 10447)

When using an <input type="text"> element in an HTML page, htmlInstaller does not populate values so they can be used by components.

The sample configuration.xml has an element <input type="text" id="TestValueFromHtml" />, but any value put in this box is not visible to components (the log says: "Setting user-defined edit value 'TestValueFromHtml'=")

I think the solution is to use the element's value (elt.get_value().to_string()) instead of it's HTML contents (elt.get_html(false)). This resolves the issue in my testing; the log file shows the value when calling the MSI component.

configuration.xml

<?xml version="1.0" encoding="utf-8"?>
<configurations lcid_type="UserExe" show_language_selector="False" language_selector_title="" language_selector_ok="OK" language_selector_cancel="Cancel" configuration_no_match_message="" ui_level="full" fileversion="" productversion="" log_enabled="True" log_file="dotNetInstallerLog.log">
  <schema version="2.1.528.0" generator="dotNetInstaller InstallerEditor" />
  <configuration dialog_caption="APPLICATION_NAME Installer" dialog_message="In order to install APPLICATION_NAME you must first install these components:" dialog_message_uninstall="" dialog_bitmap="#APPPATH\banner.bmp" skip_caption="Skip" install_caption="Install" uninstall_caption="Uninstall" cancel_caption="Close" status_installed=" (Installed)" status_notinstalled="" failed_exec_command_continue="Failed to install %s. Continue with other components?" installation_completed="APPLICATION_NAME installed successfully!" uninstallation_completed="APPLICATION_NAME installed successfully!" installation_none="APPLICATION_NAME is already installed!" uninstallation_none="APPLICATION_NAME is not installed!" installing_component_wait="Installing %s. Wait, this operation could take some time ..." uninstalling_component_wait="Installing %s. Wait, this operation could take some time ..." reboot_required="To continue the installation you must restart your computer. Restart now?" must_reboot_required="False" dialog_otherinfo_caption="" dialog_otherinfo_link="" complete_command="" complete_command_silent="" complete_command_basic="" wait_for_complete_command="True" auto_close_if_installed="True" auto_close_on_error="False" reload_on_error="True" dialog_show_installed="True" dialog_show_uninstalled="True" dialog_show_required="True" cab_dialog_message="%s" cab_cancelled_message="" cab_dialog_caption="" cab_path="#TEMPPATH\#GUID" cab_path_autodelete="True" dialog_default_button="cancel" dialog_position="" dialog_components_list_position="" dialog_message_position="" dialog_bitmap_position="" dialog_otherinfo_link_position="" dialog_osinfo_position="" dialog_install_button_position="" dialog_cancel_button_position="" dialog_skip_button_position="" auto_start="False" auto_continue_on_reboot="False" reboot_cmd="" show_progress_dialog="True" show_cab_dialog="True" disable_wow64_fs_redirection="False" administrator_required="False" administrator_required_message="APPLICATION_NAME installation requires administration rights." type="install" lcid_filter="" language_id="" language="" os_filter="" os_filter_min="" os_filter_max="" processor_architecture_filter="" supports_install="True" supports_uninstall="True">
    <component package="#APPPATH\mysetup.msi" cmdparameters="/1 [TestValueFromHtml] /2" cmdparameters_silent="/qn" cmdparameters_basic="/qb-" uninstall_package="" uninstall_cmdparameters="/qb-" uninstall_cmdparameters_silent="/qn" uninstall_cmdparameters_basic="/qb-" disable_wow64_fs_redirection="False" id="mysetup.msi" display_name="mysetup.msi" uninstall_display_name="" os_filter="" os_filter_min="" os_filter_max="" os_filter_lcid="" type="msi" installcompletemessage="" uninstallcompletemessage="" mustreboot="False" reboot_required="" must_reboot_required="False" failed_exec_command_continue="" allow_continue_on_error="True" default_continue_on_error="False" required_install="True" required_uninstall="True" selected_install="True" selected_uninstall="True" note="" processor_architecture_filter="" status_installed="" status_notinstalled="" supports_install="True" supports_uninstall="True" show_progress_dialog="True" show_cab_dialog="True" />
  </configuration>
</configurations>

index.html

<html>
  <head>
  </head>
  <body>
    <div id="content">
      <div id="components" />
      <input type="text" id="TestValueFromHtml" value="123" />
      <div id="buttons">
        <input id="button_install" type="button" value="Install" />
      </div>
    </div>
  </body>
</html>

@dblock

dblock commented Jun 19, 2012

Copy link
Copy Markdown
Collaborator

This is cool, but we really, really need a test for this before a merge. If you have hard time writing one I'd be happy to give it a shot this week.

@dblock

dblock commented Jun 19, 2012

Copy link
Copy Markdown
Collaborator

Also, please update CHANGELOG.md part of the request. Appreciated.

htmlInstaller appears to be using the inner HTML contents of any <input type="text"> elements. It should use the value of those elements instead.
@jennings

Copy link
Copy Markdown
Contributor Author

Hrm... the problem seems to be in the "convert the HTML form elements into control args" step, but there are no tests for that yet that I can see.

I started to write a test based on UserControlUnitTests.TestUserControlEdit(), but realized that I can't specify an HTML file for the installer unless I compile it with InstallerLinker. It looks like htmlInstaller always looks either in the directory it runs from, or from an embedded resource.

I'm not quite sure how to write a test for this without restructuring a lot more things, a task which is likely quite beyond my capability.

@jennings

Copy link
Copy Markdown
Contributor Author

I pushed a new branch text-value-bad showing what I was about to try. The test doesn't pass because htmlInstaller doesn't find index.html where I put it, and dotNetInstaller.exe will never pass the test since it doesn't know about HTML UIs.

@dblock

dblock commented Jun 19, 2012

Copy link
Copy Markdown
Collaborator

I am not saying it's going to be easy :)

There's a .NET project called dotNetInstallerUnitTests under unittests that creates a configuration file, links it and runs it. That executes with either DNI or htmlInstaller, do a build unittests to see it run. It takes a generated config file to know what to run. There're a bunch of tests that work this way, a couple about exit code should be a good model maybe.

Start without a fix. There should be a way to reuse the value of a custom variable to signal an exit code via a component. So you could make a setup fail this way. With the fix it should read the value properly and return a 0 error code, succeeding.

@jennings

Copy link
Copy Markdown
Contributor Author

I worked at it tonight and got to commit 578b64e, but still isn't a passing test.

It seems that when the UI level is silent, htmlInstaller.exe only populates user controls with whatever is in the config file. When the UI level is full, it uses values from the HTML.

So if this test were running under full UI, it would pass, but since I'm using silent UI, it doesn't. I think the current behavior makes sense (use the configuration file for default values, then override them with HTML values when running in full UI mode).

@dblock

dblock commented Jun 19, 2012

Copy link
Copy Markdown
Collaborator

It takes a couple more auto-start options to get it to run in full UI, here're the changes. Should get you further.

@jennings

Copy link
Copy Markdown
Contributor Author

The test passes now. If I revert jennings/dotnetinstaller@5d1e417, the test fails, although it fails for a different reason than I expected. The installer just stays open, then the test fails when you manually close it. I'm not entirely sure why that difference in behavior exists.

@dblock dblock merged commit 39d0d8e into dotnetinstaller:master Jun 19, 2012
@dblock

dblock commented Jun 19, 2012

Copy link
Copy Markdown
Collaborator

The installer stays open cause the command hangs. And it hangs because the edit field doesn't have a value (which is the bug) and so it tries to do cmd.exe /C exit /b without a parameter, so cmd runs and waits. This is easily fixed with `cmd.exe /C exit /b [edit1]1', so we'll get a value of 41 when it worked and 1 when it didn't. I made a commit on top of this with the change.

Thanks so much for doing this work, much appreciated and merged.

@jennings

Copy link
Copy Markdown
Contributor Author

Thanks for the guidance with the test.

@aghor

aghor commented Apr 17, 2013

Copy link
Copy Markdown

Hi,
please can anyone tel me where I found a full documentation about how to use htmlinstaller

thanks

@dblock

dblock commented Apr 18, 2013

Copy link
Copy Markdown
Collaborator

@AGho please ask the mailing list if what's in the CHM is not sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants