Wix custom UI for SQL Database installation

2019-03-04 14:17发布

This is my very first wix project. I downloaded wix 3.6 rc. My installation project includes 2 wcf and 1 silverlight projects. Everything works fine with default Wix UI. But now that I need to add sql database to it. It works fine with default values like below:

                  <Component Id='SqlComponent' Guid='8B72C159-1477-4A58-AFAE-E94D756BFFA6'>
                    <CreateFolder/>
                    <sql:SqlDatabase Id='SqlDatabase' Database='master' Server='.'
                      CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='yes'>
                      <sql:SqlScript Id='CreateTable' BinaryKey='CreateTable' ExecuteOnInstall='yes' />
                      <sql:SqlScript Id='CreateTable1' BinaryKey='CreateTable1' ExecuteOnInstall='yes' />
                    </sql:SqlDatabase>
                  </Component>

But I need to present a user interface for sql database path, database name, user name and password, if user and password is not specified then use windows user.

Just to see how to add a custom ui I tried the following: but it displays the custom ui right away. But I want it to show specifically for sql database installation only.

<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
  <Text>Ready to Install</Text>
</Control>

<Control Id="Install" Type="PushButton" X="304" Y="243" Width="56" Height="17"
    Default="yes" Text="Install">
  <Publish Event="EndDialog" Value="Return" />
</Control>

I guess, once I get it to show the custom UI exactly where I want, my next requirement is going to be able to get user input for database path, name, user and password and pass that information to the script. I'm not sure how to do that either.

标签: wix
2条回答
该账号已被封号
2楼-- · 2019-03-04 14:41

Read up on the WiX UI extension in the .chm. Choose the dialog set that is most appropriate for your installer. Then you can customize it accordingly. Let's assume you want to customize the WixUI_Advanced dialog set:

  • Download the WiX source code
  • Navigate to the source code for the UI extension located in src\ext\UIExtension\wixlib.
  • Copy and rename the file *WixUI_Advanced.wxs* to something different such as *WixUI_Advanced_Custom.wxs*.
  • Open the .wxs file and be sure to rename the UI Id to <UI Id="WixUI_Advanced_Custom">.
  • Add *WixUI_Advanced_Custom.wxs* to your setup project.

Now you can reference your custom dialog set just like you would reference the other dialog sets in the UI extension. But the UI is not quite customized, it just provides the same functionality as the WixUI_Advanced dialog set. To add a new dialog, you need to create a new .wxs using the wix source as an example. Look at any of the dialogs in src\ext\UIExtension\wixlib for help. Then reference your dialog in *WixUI_Advanced_Custom.wxs* by adding and modifying the <Publish> elements to determine when your dialog is shown.

查看更多
Luminary・发光体
3楼-- · 2019-03-04 14:48

Finally I found an eye opener article on wix here How to add custom UI

After a long struggle to understand how wix works, the above link to codeproject helped me understand. Especially the part that explains creating UI (MyWebUI.wxs in that article) was the life saver.

查看更多
登录 后发表回答