Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Creating a Localized Windows Installer & Bootstrapper: Part 3

, 25 Feb 2013 CPOL
This series of articles is a complete end-to-end solution for building a localizable Windows Installer & Bootstrapper using some real-world requirements.
WixWindowsInstallerDemo-noexe.zip
installer
binary
Banner.bmp
Dialog.bmp
EULA_en-gb.rtf
EULA_it-it.rtf
bootstrapper
banner.bmp
Component.wxs
Config.wxi
en-GB.wxl
Installer.suo
it-IT.wxl
Main.wxs
targetfiles
MyApp.suo
tools
MsiIntel.SDK
build
MyApp.Installer.build
WixWindowsInstallerDemo.zip
Banner.bmp
Dialog.bmp
EULA_en-gb.rtf
EULA_it-it.rtf
banner.bmp
dotNetFx40_Client_setup.exe
Component.wxs
Config.wxi
en-GB.wxl
Installer.suo
it-IT.wxl
Main.wxs
MyApp.suo
MyApp
bin
Release
MyApp.exe
MyAppLibrary.dll
MyApp.Installer.build
Prerequisites.exe
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">

  <xsl:output method="xml" encoding="UTF-8" indent="yes" />

    <xsl:template match="wix:Wix">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:Component/wix:File[substring(@Source,string-length(@Source)-3)='.dll' or substring(@Source,string-length(@Source)-3)='.exe']">
	<xsl:variable name="lastslashindex">
		<xsl:call-template name="lastIndexOf">
			 <xsl:with-param name="string" select="@Source" />
			 <xsl:with-param name="char" select="'\'" />
		 </xsl:call-template>
	</xsl:variable>

	<xsl:copy>
      <xsl:apply-templates select="@*" />
      <netfx:NativeImage Priority="1">
		<xsl:attribute name="Id">
			<xsl:value-of select="$lastslashindex"/>
		</xsl:attribute>
	   </netfx:NativeImage>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  
  <xsl:template name="lastIndexOf">
   <!-- declare that it takes two parameters - the string and the char -->
   <xsl:param name="string" />
   <xsl:param name="char" />
   <xsl:choose>
      <!-- if the string contains the character... -->
      <xsl:when test="contains($string, $char)">
         <!-- call the template recursively... -->
         <xsl:call-template name="lastIndexOf">
            <!-- with the string being the string after the character
                 -->
            <xsl:with-param name="string"
                            select="substring-after($string, $char)" />
            <!-- and the character being the same as before -->
            <xsl:with-param name="char" select="$char" />
         </xsl:call-template>
      </xsl:when>
      <!-- otherwise, return the value of the string -->
      <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
   </xsl:choose>
</xsl:template>
  
</xsl:stylesheet>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

TheCodeKing
Architect
United Kingdom United Kingdom
Mike Carlisle - Technical Architect with over 15 years experience in a wide range of technologies.
 
@TheCodeKing
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 25 Feb 2013
Article Copyright 2010 by TheCodeKing
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid