Because continuous integration is required, all projects are compiled and a multi-language installation package is generated. The previous build of the MST file is manual, and the MST file must be "associated" with the new installation package each time, otherwise the Chinese installation package will call the "type conversion failed" error when it calls the English resource. Based on these two points, it is necessary to program this process, or each package will have to find me. The following is a record of the program. relatively simple.
In fact, the program calls CMD, and again, remember to add the WiX Bin directory to the system variables. Otherwise, the command is not recognized, and the program execution directory points to the destination directory.
Static voidMain (string[] args) { if(args. Length <1) { return; } Console.WriteLine (args[0]); varPath = args[0]; //var path =msipath;Console.WriteLine ("being executed:"+DateTime.Now); varp =NewProcess {startinfo={FileName="Cmd.exe", UseShellExecute=false, Redirectstandardinput=true, Redirectstandardoutput=true, Redirectstandarderror=true, CreateNoWindow=false, workingdirectory = Path }}; Try{P.start (); if(!Init (P, path)) {Console.WriteLine ("initialization failed"); P.close (); return; } //Merging LanguagesExccomand (P, COMMANDLINES.LANZH_TW); Exccomand (P, COMMANDLINES.LANZH_CN); Exccomand (P, Commandlines.lanen_us); //Associated LanguagesExccomand (P, COMMANDLINES.COMBANLANZH_CN); //test the installation package//Exccomand (P, COMMANDLINES.TESTZH_TW); //p.waitforexit ();P.close (); Console.WriteLine (" Complete"+DateTime.Now); } Catch(Exception E1) {Console.WriteLine ("Error"+E1. Message); } }
Initialize to ensure that the installation files, VBS files, and MST files are present.
Private Static string[] LANs = {"ZH-CN","en -US","ZH-TW" }; Private Static BOOLInit (Process p,stringpath) { //whether the multilingual installation package exists foreach(varLaninchLANs) { varLanpath =path.combine (Path, LAN, Softname); if(!file.exists (Lanpath)) {Console.WriteLine ("{0} installation package does not exist! ", LAN); return false; } } //Guaranteed Two filesCopyfileifnotexist (Path,"Wixsubstg.vbs"); Copyfileifnotexist (Path,"Wilangid.vbs"); //whether the Morph file exists varTwmst = Path.Combine (Path,"transforms","Zh-tw.mst"); if(!file.exists (TWMST)) {gettransforms (P); } //one more Test . returnfile.exists (TWMST); }
These two VBS files are available in tutorial 13. The last time you check the MST file is to make sure that the MST file exists. Morphing files are key to our multi-language installation package.
/// <summary> ///creating a Morph file/// </summary> /// <param name= "p" ></param> Private Static voidgettransforms (Process p) {Exccomand (P, Commandlines.entozh); Exccomand (P, COMMANDLINES.ENTOTW); Exccomand (P, Commandlines.zhtoen); } Private Static voidExccomand (Process p,stringcommand) {p.standardinput.writeline (command); Console.WriteLine ("command:"+command); Thread.Sleep ( the); }
View Code
And commandlines This class contains the command that will be used this time.
Public classCommandlines {//corresponding to traditional Public Static stringLANZH_TW =@"wixsubstg.vbs zh-cn\diaviewsetup.msi transforms\zh-tw.mst 1028"; //corresponding Chinese Public Static stringLANZH_CN =@"wixsubstg.vbs zh-cn\diaviewsetup.msi transforms\zh-cn.mst 2052"; //corresponding English Public Static stringLanen_us =@"wixsubstg.vbs Zh-cn\diaviewsetup.msi Transforms\en-us.mst 1033"; //Synthetic language installation package, default is Chinese Public Static stringCOMBANLANZH_CN =@"wilangid.vbs Zh-cn\diaviewsetup.msi Package 1028,2052,1033"; //test the traditional installation package Public Static stringTESTZH_TW =@"msiexec/i Zh-cn\diaviewsetup.msi transforms=transforms\zh-tw.mst"; //Test Chinese installation package Public Static stringTESTZH_CN =@"msiexec/i Zh-cn\diaviewsetup.msi transforms=transforms\zh-cn.mst"; //test the English installation package Public Static stringTesten_us =@"msiexec/i Zh-cn\diaviewsetup.msi transforms=transforms\en-us.mst"; //Generate English Resources Public Static stringEntozh =@"torch.exe-t language En-us\diaviewsetup.msi zh-cn\diaviewsetup.msi-out transforms\zh-cn.mst"; //Generate Chinese Resources Public Static stringENTOTW =@"torch.exe-t language En-us\diaviewsetup.msi zh-tw\diaviewsetup.msi-out transforms\zh-tw.mst"; //Generate traditional Resources Public Static stringZhtoen =@"torch.exe-t language Zh-cn\diaviewsetup.msi en-us\diaviewsetup.msi-out transforms\en-us.mst"; }
View Code
The results of the final implementation are as follows. This is based on ZH-CN. The installation package after compositing can automatically switch languages based on the system environment, and displays the default language if it is not one of the associated languages.
Of course, the main purpose is to allow him to display different language interfaces depending on the user's choice.
Wix Installation Deployment Tutorial (16)--automatic generation of multilingual files