2011-09-14 120 views
2

試圖製作一個多語言安裝程序 - 該過程通常工作,但似乎無法安裝本地化文件。MST爲什麼不包含具有不同內容的文件

每個本地化安裝程序都可以獨立運行並安裝本地化文件,如eula.pdf。

我希望,我只是缺少變換生成步驟的標誌(或者使用了錯誤的工具?)

過程由有一羣爲每種語言安裝1開始。

要構建每個安裝程序,我們使用-b "folder"-loc "folder"選項指定每個語言,其中包含一些替代文件內容,如licence.pdf。

進行本地化的文件有一個共同的源名稱

<File Id='License.pdf' Name='eula.pdf' Source='License(EULA).pdf' KeyPath='yes'/> 
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" /> 

例如是

en-US/License(EULA).pdf 
en-US/License.rtf 
en-US/Product.wxl 
fr-FR/License(EULA).pdf 
fr-FR/License.rtf 
fr-FR/Product.wxl 

也有一些文件,如文件夾binary.dll和binary.exe未本地化並且對所有msi都一樣 - 不要期望在MST中看到它們。

該過程中的下一步是在基本語言(英語)和其他每種語言之間創建一個MST差異。使用Window SDK中的Windows\v7.1\Bin\MsiTran.exe

對於內容更改,MST看起來有點小。

使用Windows\v7.1\Samples\sysmgmt\msi\scripts\wisubstg.vbs

除英語之外的語言安裝合併所有MST文件到一個單一的安裝程序將顯示整個安裝程序UI包括許可證爲被本地化的RTF版本,但在磁盤上的EULA.pdf是永遠是基礎英語。

使用Ant-DOTNET任務運行構建(如果它有差別) 微星建設任務

<wix mode="light" target="${outlocation}\${lang.folder}\my.msi" wixHome="${wixhome}"> 
     <lightArg line="-b &quot;${location}&quot;"/> <!-- provide the location of the signable binaries --> 
     <lightArg line="-b &quot;${msiwixsource}\Localisation\${lang.folder}&quot;"/> <!-- provide the location of the localisation --> 
     <lightArg line="-sice:ICE57"/> 
     <lightArg line="-cultures:${lang.culture}"/> 
     <lightArg line="-loc &quot;${msiwixsource}\Localisation\${lang.folder}\Product.wxl&quot;"/> 
     <lightArg line="-ext &quot;${wixhome}\WixUtilExtension.dll&quot;"/> 
     <lightArg line="-ext &quot;${wixhome}\WixUIExtension.dll&quot;"/> 
     <lightArg line="-ext &quot;${wixhome}\WixFirewallExtension.dll&quot;"/> 
     <lightArg line="-ext &quot;${wixhome}\WixNetFxExtension.dll&quot;"/> 
     <sources dir="${msiwixobjects}"> 
      <include name="*.wixobj"/> 
     </sources> 
     <moresources dir="${msiwixsource}\Localisation\${lang.folder}"> 
      <include name="*"/> 
     </moresources> 
     <moresources dir="${location}"> 
      <include name="binary.dll,binary.exe"/> 
     </moresources> 
    </wix> 

變換任務

<exec executable="${windowsSDKBin}"> 
     <arg value="-g"/> 
     <arg value="${outlocation}\en-US\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.mst"/> 
    </exec> 

的重新包裝任務

<exec executable="cscript"> 
     <arg value="${windowsSDKMsi}"/> 
     <arg value="${outlocation}\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.mst"/> 
     <arg value="${lang.id}"/> 
    </exec> 

Product/@ Language =「!(loc.Lang)」在Product.wxl中指定 英文基地我們列出所有1033,1028,1029,1031,1036,1040,1041,1043,1045,1046,2052,3082其他語言只是具體的如1036 fr-FR

回答

2

好吧,所以經過幾天的搜索,我找到了一篇文章,描述了這個問題。 How To Localize the Setup GUI and Deliver Localized Files Using a MST

問題在於MST不包括'_Streams'表格元素,這是CAB文件的存儲位置。

你可以從你那去幾個方面 -

1)使多個文件&組件條目與條件包含基於語言或文化

這意味着改變你的WXS,如果你想在不同的語言更改支持哪些語言。

<Component Directory="INSTALLDIR" Id='EULADoc' Guid='***'> 
    <Condition><![CDATA[(ProductLanguage = "1033")]]></Condition> 
    <File Id='License.pdf' Name='!(loc.EULA)' Source='en-US\License(EULA).pdf' KeyPath='yes'/> 
</Component> 
<Component Directory="INSTALLDIR" Id='EULADoc' Guid='***'> 
    <Condition><![CDATA[(ProductLanguage = "1046")]]></Condition> 
    <File Id='License.pdf' Name='!(loc.EULA)' Source='pt-BR\License(EULA).pdf' KeyPath='yes'/> 
</Component> 
... add a new block each time you add a language, changes to files have to be duplicated for every block. 

這又意味着重新編譯而不是重新鏈接wxl。您仍然需要重新包裝mst文件。

2)手動調整局部MSI

作爲每How To Localize the Setup GUI and Deliver Localized Files Using a MST

3)自動分割局部項放入一個單獨的CAB具有局部名

比相反重新編譯這個然後重新鏈接和用於管理CAB文件額外的工藝。 額外的過程,以 - *提取的CAB文件(s)一起生成mst,
*然後當合並mst還添加cab文件。

添加具有本地化名稱額外的媒體 - 我使用的是郎ID,因爲它是方便

<Media Id="2" Cabinet="localised_!(loc.LANG).cab" EmbedCab="yes" /> 

更改本地化的文件/組件來自於新媒體

<Component Directory="INSTALLDIR" Id='EULADoc' Guid='***' DiskId='2'> 
    <File Id='License.pdf' Name='!(loc.EULA)' Source='License(EULA).pdf' KeyPath='yes'/> 
</Component> 

當使用MSITran.exe生成轉換時,還使用MsiDb.Exe 導出本地化CAB文件當使用WiSubStg.vbs將轉換合併到基本MSI時,還將CAB文件添加到_Streams使用WiStram.vbs

我已經與選項3 我希望別人認爲這很有用。 注:

  • 我就不寫了ANT的很多可以隨意
  • 我們建立一個無符號的測試和發佈簽名版本提供建議,以便需要調整輸入/輸出位置找到二進制文件和msi。

和ant構建看起來如下所示。

<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="buildjars"/> 
<taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="buildjars"/> 
<taskdef name="wix" classname="org.apache.ant.dotnet.wix.WixTask" classpathref="buildjars"/> 

<property name="wixhome" value="C:\Program Files (x86)\Windows Installer XML v3.5\bin"/> 

<property name="binarieslocation" value="build"/> 
<property name="msiwixsource" value="install"/> 
<property name="msiwixobjects" value="${msiwixsource}\obj\x64\Release"/> 
<!-- <dirname property="windowsSDK" file="C:\Program Files\Microsoft SDKs\Windows\v7.1\"/> Ant doesn't like path segments with . --> 
<property name="windowsSDKBin" location="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\MsiTran.exe"/> 
<property name="windowsSDKCab" location="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\MsiDb.Exe"/> 
<property name="windowsSDKMsiStorage" location="C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiSubStg.vbs"/> 
<property name="windowsSDKMsiStream" location="C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiStream.vbs"/> 
<property name="windowsSDKMsiLanguages" location="C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiLangId.vbs"/> 

<property name="cultureBase" value="en-US:en-US:1033"/> 
<property name="cultures" value="pt-BR:pt-BR:1046,cs-CZ:en-US:1029"/> 

<target name="installer"> 
    <echo>Building ${culture} msi using binaries in "${location}"...</echo> 
    <propertyregex property="lang.folder" input="${culture}" regexp="(.*):(.*):(.*)" select="\1"/> 
    <propertyregex property="lang.culture" input="${culture}" regexp="(.*):(.*):(.*)" select="\2"/> 

<wix mode="light" target="${outlocation}\${lang.folder}\my.msi" wixHome="${wixhome}"> 
    <lightArg line="-b &quot;${location}&quot;"/> <!-- provide the location of the signable binaries --> 
    <lightArg line="-b &quot;${msiwixsource}\Localisation\${lang.folder}&quot;"/> <!-- provide the location of the localisation --> 
    <lightArg line="-sice:ICE57"/> 
    <lightArg line="-cultures:${lang.culture}"/> 
    <lightArg line="-loc &quot;${msiwixsource}\Localisation\${lang.folder}\Product.wxl&quot;"/> 
    <lightArg line="-ext &quot;${wixhome}\WixUtilExtension.dll&quot;"/> 
    <lightArg line="-ext &quot;${wixhome}\WixUIExtension.dll&quot;"/> 
    <sources dir="${msiwixobjects}"> 
     <include name="*.wixobj"/> 
    </sources> 
    <moresources dir="${msiwixsource}\Localisation\${lang.folder}"> 
     <include name="*"/> 
    </moresources> 
    <moresources dir="${location}"> 
     <include name="binary.dll,binary.exe"/> 
    </moresources> 
</wix> 

</target> 

<target name="checkTransform" depends="installer"> 
    <uptodate property="transform.notRequired" targetfile="${outlocation}\${culture}\my.mst" > 
     <srcfiles dir= "${outlocation}\en-US\" includes="my.msi"/> 
     <srcfiles dir= "${outlocation}\${lang.culture}\" includes="my.msi"/> 
    </uptodate> 
</target> 

<target name="transform" depends="checkTransform" unless="transform.notRequired"> 
    <echo>Building ${culture} mst ...</echo> 
    <propertyregex property="lang.folder" input="${culture}" regexp="(.*):(.*):(.*)" select="\1"/> 
    <propertyregex property="lang.id" input="${culture}" regexp="(.*):(.*):(.*)" select="\3"/> 

    <!-- Generate the mst 'diff' file - this does not include exporting the language specific cab file to match --> 
    <exec executable="${windowsSDKBin}"> 
     <arg value="-g"/> 
     <arg value="${outlocation}\en-US\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.mst"/> 
    </exec> 

    <!-- Exporting the language specific cab file to match --> 
    <delete file="localised_${lang.id}.cab" /> 
    <delete file="${outlocation}\${lang.folder}\localised_${lang.id}.cab" /> 
    <exec executable="${windowsSDKCab}"> 
     <arg value="-d"/> 
     <arg value="${outlocation}\${lang.folder}\my.msi"/> 
     <arg value="-x"/> 
     <arg value="localised_${lang.id}.cab"/> 
    </exec> 
    <move file="localised_${lang.id}.cab" tofile="${outlocation}\${lang.folder}\localised_${lang.id}.cab"/> 
</target> 

<!-- Target to build MSIs using unsigned binaries --> 
<target name="MSIs"> 
    <!-- we always need english as it is the base multilingual --> 
    <antcall target="installer"> 
     <param name="culture" value="${cultureBase}" /> 
     <param name="location" value="${location}" /> 
     <param name="outlocation" value="${outlocation}" /> 
    </antcall> 
    <!-- build the different cultures and make transforms 
    parallel="true" sometimes fails--> 
    <for list="${cultures}" param="culture" > 
     <sequential> 
     <antcall target="transform"> 
      <param name="culture" value="@{culture}" /> 
      <param name="location" value="${location}" /> 
      <param name="outlocation" value="${outlocation}" /> 
     </antcall> 
     </sequential> 
    </for> 
</target> 

<!-- depends="transform" --> 
<target name="transformRepack" > 
    <echo>Packing ${culture} mst into multilingual installer...</echo> 
    <propertyregex property="lang.folder" input="${culture}" regexp="(.*):(.*):(.*)" select="\1"/> 
    <propertyregex property="lang.id" input="${culture}" regexp="(.*):(.*):(.*)" select="\3"/> 

    <exec executable="cscript"> 
     <arg value="${windowsSDKMsiStream}"/> 
     <arg value="${outlocation}\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\localised_${lang.id}.cab"/> 
     <arg value="localised_${lang.id}.cab"/> 
    </exec> 
    <exec executable="cscript"> 
     <arg value="${windowsSDKMsiStorage}"/> 
     <arg value="${outlocation}\my.msi"/> 
     <arg value="${outlocation}\${lang.folder}\my.mst"/> 
     <arg value="${lang.id}"/> 
    </exec> 
</target> 

<target name="MSIMulti" depends="MSIs"> 
    <echo>Making multilingual installer...</echo> 

    <copy file="${outlocation}\en-US\my.msi" todir="${outlocation}"/> 

    <for list="${cultures}" param="culture"> 
     <sequential> 
     <antcall target="transformRepack"> 
      <param name="culture" value="@{culture}" /> 
      <param name="location" value="${location}" /> 
      <param name="outlocation" value="${outlocation}" /> 
     </antcall> 
     </sequential> 
    </for> 
    <!-- report what was packed --> 
    <propertyregex property="lang.ids" input="${cultures}" regexp="([^:,]*):([^:]*):([^,]*)" replace="\3" global="true" defaultvalue="failed"/> 
    <echo/> 
    <echo>Multilingual installer should include transform language ids </echo> 
    <echo>${lang.ids}</echo> 
    <echo>Multilingual installer reports transform language ids...</echo> 
    <exec executable="cscript"> 
     <arg value="${windowsSDKMsiStorage}"/> 
     <arg value="${outlocation}\my.msi"/> 
    </exec> 
    <exec executable="cscript"> 
     <arg value="${windowsSDKMsiLanguages}"/> 
     <arg value="${outlocation}\my.msi"/> 
     <arg value="Package"/> 
     <arg value="1033,${lang.ids}"/> 
    </exec> 
</target> 

<target name="UnsignedMSIMulti" > 
    <antcall target="MSIMulti"> 
     <param name="location" value="${binarieslocation}" /> 
     <param name="outlocation" value="${binarieslocation}" /> 
    </antcall> 
</target> 
相關問題