Skip to content

Instantly share code, notes, and snippets.

@psfrolov
Created April 25, 2015 07:58
Show Gist options
  • Save psfrolov/aa8b0eaa4edcb6cdc303 to your computer and use it in GitHub Desktop.
Save psfrolov/aa8b0eaa4edcb6cdc303 to your computer and use it in GitHub Desktop.
Creating multi-language MSI package with MSBuild
<Target Name="AfterBuild">
<!-- Set inputs & outputs for CreateLanguageTransforms. -->
<ItemGroup>
<MsiForTransform
Include="$(OutputDir)\%(CultureGroup.OutputFolder)$(OutputFullName)"
Exclude="$(OutputDir)\en-US_\$(OutputFullName)"
/>
<Transform
Include="$(OutputDir)\%(CultureGroup.OutputFolder)%(CultureGroup.Identity).mst"
Exclude="$(OutputDir)\en-US_\%(CultureGroup.Identity).mst"
/>
</ItemGroup>
</Target>
<Target
Name="CreateLanguageTransforms"
AfterTargets="AfterBuild"
Condition="'$(OutputType)' == 'Package'"
Inputs="@(MsiForTransform)"
Outputs="@(Transform)">
<!-- Create *.mst files. -->
<Torch
ToolPath="$(WixToolPath)"
NoLogo="$(NoLogo)"
AdditionalOptions="-pedantic -wx"
PreserveUnmodifiedContent="true"
TransformValidationType="language"
BaselineFile="$(OutputDir)\en-US_\$(OutputFullName)"
UpdateFile="@(MsiForTransform)"
OutputFile="@(Transform)">
<Output TaskParameter="OutputFile" ItemName="LanguageTransform"/>
</Torch>
</Target>
<Target Name="EmbedLanguageTransforms"
AfterTargets="CreateLanguageTransforms"
Condition="'$(OutputType)' == 'Package'"
Inputs="@(LanguageTransform);$(IntMsiAbsPath);$(MSBuildThisFileFullPath)"
Outputs="$(IntermediateOutputPath)EmbedLanguageTransforms.dep">
<!-- Create LangId list from LangIds. -->
<ItemGroup>
<LangId Include="$(LangIds.Split(','))" Exclude="1033"/>
<Culture Include="@(CultureGroup)" Exclude="en-US_,en-US">
<LangId>%(LangId.Identity)</LangId>
</Culture>
</ItemGroup>
<!-- Copy "en-US" MSI pacakge. -->
<Copy
SourceFiles="$(OutputDir)\en-US_\$(OutputFullName)"
DestinationFolder="$(OutputDir)\int"
SkipUnchangedFiles='true'
/>
<!-- Embed language transforms & update package languages. -->
<Exec Condition="@(Culture) != ''"
Command="
CScript $(MsiToolsPath)\wisubstg.vbs //Nologo //E:VBScript $(OutputDir)\int\$(OutputFullName) @(LanguageTransform) %(Culture.LangId)
CScript $(MsiToolsPath)\wilangid.vbs //Nologo //E:VBScript $(OutputDir)\int\$(OutputFullName) Package 1033,@(LangId)
"
/>
<Touch
Files="$(IntermediateOutputPath)EmbedLanguageTransforms.dep"
AlwaysCreate="True"
/>
</Target>
<!-- Sign international MSI. -->
<Target Name="SignIntMsi" AfterTargets="EmbedLanguageTransforms"
Condition="'$(OutputType)' == 'Package' AND '$(Configuration)' == 'Release'"
Inputs="$(IntMsiAbsPath);$(MSBuildThisFileFullPath)"
Outputs="$(IntermediateOutputPath)SignIntMsi.dep">
<Exec Command="&quot;$(SignToolPath)&quot; sign /t $(TimestampServerUrl) /sha1 $(CertificateThumbprint) /sm /d &quot;$(MsiFileDescription)&quot; /du $(VendorUrl) $(IntMsiAbsPath)"/>
<Touch Files="$(IntermediateOutputPath)SignIntMsi.dep" AlwaysCreate="True"/>
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment