creating language selection dialog using WiX

2019-03-31 23:55发布

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:

enter image description here

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.

2条回答
放荡不羁爱自由
2楼-- · 2019-03-31 23:58

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.

查看更多
乱世女痞
3楼-- · 2019-04-01 00:03

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.

查看更多
登录 后发表回答