creating language selection dialog using WiX

怎甘沉沦 提交于 2019-12-05 02:14:32

问题


I have a created a multilanguage installer using WiX. I am running the installer from command line using command "msiexec /i myinstaller.msi TRANSFORMS=":1041" and it is working fine. Now I have created a language selection dialog using bootstrapper. How can I pass the selected language to my WiX installer to launch as per selected language? I got this idea from following links:

  1. Can we localize WIX msi and bundle using language selection UI at runtime?
  2. http://wix.tramontana.co.hu/tutorial/transforms/morphing-installers

My bundle has <MsiPackage SourceFile="myinstaller.msi" DisplayInternalUI="yes" >

I have this screen as a result of my custom UI using Burn from WiX toolset:

I want somehow to execute command msiexec /i myinstaller.msi TRANSFORMS=":1041" if I select Japanese or msiexec /i myinstaller.msi TRANSFORMS=":1031" if I select German and press OK.

Please tell me what I should do for this problem. Is there any other way to do this? If yes, then please tell me. Some code sample would be a better help.


回答1:


Unfortunately, the transform must be applied as the MSI is being opened. That means, you will need that bootstrapper up front to pass the appropriate command-line to the Windows Installer to apply the correct transform.

After getting the UI in the bootstrapper to ask the user what language to display, (combobox or something?) I'd probably just do a ShellExecute() and format the command-line arguments like:

("/i myinstaller.msi TRANSFORMS=\":%d\", dwLanguageIdFromComboBox)

That would launch the installer with the right UI and your bootstrapper can go away.




回答2:


Finally I got the solution. Bootstrapper UI for language selection can be created as described here. After that, I wrote following code in my button click event to launch the msi in selected language:

Bootstrapper.Engine.StringVariables["CommandArgs"] = ":1031";
Bootstrapper.Engine.Plan(Wix.LaunchAction.Install);
break;
....
....
this.Close(); //outside of switch statement
break;

The above code will use CommandArgs as an MSI property.Then I added following code to my bundle.wxs file

<MsiPackage Id="mypackage" SourceFile="myinstaller.msi" DisplayInternalUI="yes">
   <MsiProperty Name="TRANSFORMS" Value="[CommandArgs]"/>
</MsiPackage>

Worked exaclty the way I wanted. This code is same as launching msi from command line using following command

msiexec /i myinstaller.msi TRANSFORMS=":1031"

The only issue is that it is taking some time to launch MSI after language is selected from above UI.



来源:https://stackoverflow.com/questions/16423808/creating-language-selection-dialog-using-wix

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