Wix installation Deployment (ii) Custom installation interface and behavior

Source: Internet
Author: User

This will be on the basis of the above to continue to explore WiX's custom interface and behavior of the function, the following are personal summary, improper welcome to correct, and June Mutual encouragement!

First, the Installation Wizard

WiX offers five installation wizard styles,

    • Wixui Advanced
    • Wixui Featuretree
    • Wixui InstallDir
    • Wixui Minimal
    • Wixui Mondo

How to use it? It takes two steps to get started without asking why:

1. You need to use the uiref element, which is introduced in product

  <UI> <uiref id= "Wixui_minimal"/></ui>

2. Then right-click on the installation project to add a reference to WixUIExtension.dll, which is in the WiX bin directory you installed. We generate the following again, this time click on the installation file, the Installation Wizard page appears, first agreed to the license, and then the next step, and so on the button to know the completion, than the installation in the previous article is obviously presentable. Do not hurry down, and then look back at the following

UI elements are designed to standardize the installation UI, where you can define the style you choose, set custom behavior, and so on. Uiref used to choose the Installation Wizard style, the ID of the minmal to replace it, Minmal is the most concise. Of course you can't have two uiref, or WiX will be messy.

Additional settings are required for advance and installdir.

InstallDir requires a property that allows the user to define where to install. As follows:

<directory id= "TARGETDIR" name= "SourceDir" >  <directory id= "ProgramFilesFolder" name= "Pfiles" >    <directory id= "Testfileproductdir" name= "Test File" >      ...    </Directory>   </directory></directory>...<property id= "Wixui_installdir" value= " Testfileproductdir "/><uiref id=" Wixui_installdir "/>

Of course, remember to modify

When installed, it will let the user choose the installation location.

WixUIExtension.dll is a library of WiX's own libraries, as well as other link libraries such as wixutilextension,wixnetfxextension,wixiisextension, which will be explored later in one by one.

Second, custom style

The main point here is to add their own text and pictures, the default is a few background pictures with WiX, when the official release, of course, should be replaced by their own products related.

1. Modify the License form. The license requires Rich Text Format of RTF, we can use Word to write the content first, and then save the file as select Rich-text format to save the line, and then paste directly into the project directory. Then add the following code to the product tag, LICENSE.RTF is your license certificate. Generated again, installed on the first page to see.

    <wixvariable id= "wixuilicensertf" value= "License.rtf"/>

Wixvariable is a more advanced feature of WiX, value cannot be empty. Similarly we can replace the picture and other. Wixuidialogbmp Pictures will appear on the Welcome page and the installation Complete page, the specifications are 493x312.

Wixuibannerbmp's picture will appear just above. Spec 493x58

<wixvariable id= "wixuidialogbmp" value= "bb.jpg"/> <wixvariable id= "wixuibannerbmp" Value= "Top.jpg"/>

There are also wixuiinfoico,wixuinewico,wixuiupico,wixuiexclamationico to replace some icons.

2. Define the Exit page.

Exitdlg successfully installed after the display, you can add text, check box, let the user choose whether to execute immediately, we often see this prompt when installing the software.

Let's add a thank-you phrase and insert the following into the product element, Wixui_exitdialogoptionaltext is used to display the text.

<property id= "Wixui_exitdialogoptionaltext" value= "Thank you for installing this product."/>

Similarly, add a check box to prompt the user to run the current program.

<property id= "Wixui_exitdialogoptionalcheckboxtext" value= "Launch My application Name"/>

The interface let me change to this appearance, I think this background transparency is also a problem, this problem first noted.

But this time is still not working, let's look at the next section.

Third, execute the custom action

The small part here is because the action is a function of WiX, this time first taste. Need three steps

1. First introduce WixUtilExtension.dll

2. Use Wixshellexectarget and CustomAction to define this behavior (add in the product element)

<property id= "Wixshellexectarget" value= "[#myapplication. exe]"/><customaction id= "Launchapplication" binarykey= "Wixca" dllentry= "wixshellexec" impersonate= "yes"/>

Wixshellexectarget is designed to run an application, where the # number in value represents the full path, and this myapplication.exe is an ID that points to the ID of the file in which you installed the component. The equivalent of this property defines where the program will be executed. CustomAction defines the behavior ID is the Lanuchapplication,dllentry representation is the entry. In-depth understanding is still going to go back to the study.

3. Add the Publish element to the UI element to tell the UI how to perform this behavior.

  <UI>    <uiref id= "Wixui_minimal"/>    <publish dialog= "Exitdialog"    control= "Finish"     Event= "DoAction" value= "launchapplication" >wixui_exitdialogoptionalcheckbox = 1 and not installed</publish>  </UI>

The above two elements complete the definition of the method, where the publish is triggering this behavior. The Dialog property indicates which box (dialog), control= "Finish" means that the action is triggered by clicking the Finish key, and event= "DoAction" means that the action is executed after the click, and there should be other values that are not yet known. This value exactly points to the ID of the CustomAction. Wixui_exitdialogoptionalcheckbox = 1 indicates that the checkbox is to be checked and executed. Then, as if the world of fragments is connected together. This time, after we regenerate, install it again, select the check box and you can execute it. Looking back, why is this, WiX is the equivalent of all the configuration files, not like C # language so elegant, semantic. So it started to look really annoying. Understanding the ability to remember, each element is equivalent to a table, and this ID for each element is unique, so that through the value and ID are related to each other, and the production of MSI file is actually a database.

If you want to execute a program immediately, such as a bat file, you can add this behavior to the installation sequence to execute

   <customaction id= ' launchfile ' filekey= ' installdog ' execommand= ' return= ' asyncnowait '/>    < installexecutesequence>      <custom action= ' launchfile ' after= ' installfinalize ' >1</Custom>    </InstallExecuteSequence>
    <file source= ' $ (var. Dev) Hmirun\senselockdrivers\install.bat ' id= ' installdog ' keypath= ' yes '/>

If you want to execute a program immediately.

<customaction id= ' launchdog '    filekey= ' install.bat ' execommand= ' execute= ' immediate ' impersonate=  "Yes"  return= "asyncnowait"/><installexecutesequence>      <custom action= ' Launchdog '   after = ' installfinalize '   >1</Custom>    </InstallExecuteSequence>

Fliekey points to a bat file, but oddly enough, running this bat instantly runs out and executes for 10 seconds during installation, presumably because after= ' installfinalize ' waits for the entire installation to complete, But I changed the behavior in other installexecutesequence, but did not trigger the installation, but it was installed when I uninstalled it.

There is also a way to silently trigger a bat file. The black box does not pop up.

    <customaction id= "Service_start_cmd" property= "Qtexeccmdline" value= "&quot; [dirad8bc174523eabbbea5fe139fd0c5127]install.bat&quot; " />    <customaction id= "Service_start" binarykey= "Wixca" dllentry= "Caquietexec" execute= "immediate" Return= " Check "/>    <InstallExecuteSequence>      <custom action=" Service_start_cmd "after=" InstallFinalize " Overridable= "yes" >not installed</custom>      <custom action= "Service_start" after= "Service_start_cmd" Overridable= "yes" >not installed</custom>    </InstallExecuteSequence>

However, the Windows system under non-administrator will also pop-up prompt: Installing this driver ...  Whether the driver is properly installed. It's a little bit better than the black box, but it's not perfect.

Iv. Definition of text

All the text in the installation process can be overloaded, can be overloaded by adding a string to specify the corresponding ID, which can be used to do a separation work. Takes two steps

1. You need to add the localization file, right-click, adding New Item, select Localization file. Then use string to define your text.

<?xml version= "1.0" encoding= "Utf-8"? ><wixlocalization culture= "en-US" xmlns= "/http" Schemas.microsoft.com/wix/2006/localization ">    <string id=" ApplicationName ">**my Application Name< /string>        <string id= "Manufacturername" >my manufacturer name</string></wixlocalization>

2. Modify your product.wxs, where the expression after name points to the string id= "application" in the localization file.

<product id= "*" Name= "! (Loc. ApplicationName) ".....

The file name becomes the **my application name when you install it again, and the same goes for other places. This avoids repeated changes, allowing the separation of text and configuration.

This section first to here, today's eyes are looking at flowers, custom is more than these, tomorrow continue ....

All code:

View Code

Or that sentence, if it helps you, just top it.

Wix installation Deployment (ii) Custom installation interface and behavior

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.