如何在WiX中对文件序列进行排序?
文件表(MSI文件)中的AFAIK文件序列对卸载/安装所需的时间有影响:如果在文件表中按顺序放置具有相同目标目录的文件条目,则安装程序执行卸载/安装所需的时间少于这些文件分散在文件表中时的时间 但是,从我的wix项目构建的安装程序似乎属于后一种情况。它在文件表中分散了具有相同目标目录的文件条目。有没有办法对这些文件条目进行排序,以便它们在文件表中按顺序排列?(My.wxs文件是由heat.exe生成的)如何在WiX中对文件序列进行排序?,wix,windows-installer,Wix,Windows Installer,文件表(MSI文件)中的AFAIK文件序列对卸载/安装所需的时间有影响:如果在文件表中按顺序放置具有相同目标目录的文件条目,则安装程序执行卸载/安装所需的时间少于这些文件分散在文件表中时的时间 但是,从我的wix项目构建的安装程序似乎属于后一种情况。它在文件表中分散了具有相同目标目录的文件条目。有没有办法对这些文件条目进行排序,以便它们在文件表中按顺序排列?(My.wxs文件是由heat.exe生成的) 谢谢。WiX工具集中没有内置任何东西可以以特定方式进行排序。但是,如果您有经验证据表明应该使
谢谢。WiX工具集中没有内置任何东西可以以特定方式进行排序。但是,如果您有经验证据表明应该使用更好的排序算法,那么将其发送给wix将是一件好事-devs@lists.sourceforge.net邮件列表。WiX工具集应该自动进行最佳优化
HACK:您可以尝试按字母顺序对
文件/@Id
进行排序,以控制WiX工具集当前版本中的顺序。这可能适用于也可能不适用于所有版本的WiX工具集 WiX工具集中没有内置任何东西可以以特定方式进行排序。但是,如果您有经验证据表明应该使用更好的排序算法,那么将其发送给wix将是一件好事-devs@lists.sourceforge.net邮件列表。WiX工具集应该自动进行最佳优化
HACK:您可以尝试按字母顺序对
文件/@Id
进行排序,以控制WiX工具集当前版本中的顺序。这可能适用于也可能不适用于所有版本的WiX工具集 加热工具提供在加热结束时运行自定义XSLT转换的能力。这是一个非常强大的功能,因为它为您提供了一种方法来处理结果。例如,以下XSL将文件ID更改为所有父文件夹+文件名的串联
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:my="my:my">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='wix:File'>
<xsl:variable name='fileId'>
<xsl:value-of select="/wix:Wix/wix:Fragment/wix:DirectoryRef/@Id"/>_<xsl:value-of select="translate(substring-after(@Source, '\'), '\- ', '_')"/>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="Id">
<xsl:value-of select="$fileId"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<xsl:template match='wix:Directory'>
<xsl:variable name='parentPath'>
<xsl:for-each select='ancestor::wix:Directory/@Name'>
<xsl:value-of select="concat(.,'_')"/>
</xsl:for-each>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="Id">
<xsl:value-of select="/wix:Wix/wix:Fragment/wix:DirectoryRef/@Id"/>_<xsl:value-of select="translate($parentPath, '- ', '__')"/><xsl:value-of select="translate(@Name, '- ', '__')"/>
</xsl:attribute>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
_
_
这种方法不能保证ID的唯一性,但对我来说效果很好。加热工具提供了在加热结束时运行自定义XSLT转换的能力。这是一个非常强大的功能,因为它为您提供了一种方法来处理结果。例如,以下XSL将文件ID更改为所有父文件夹+文件名的串联
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:my="my:my">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='wix:File'>
<xsl:variable name='fileId'>
<xsl:value-of select="/wix:Wix/wix:Fragment/wix:DirectoryRef/@Id"/>_<xsl:value-of select="translate(substring-after(@Source, '\'), '\- ', '_')"/>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="Id">
<xsl:value-of select="$fileId"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<xsl:template match='wix:Directory'>
<xsl:variable name='parentPath'>
<xsl:for-each select='ancestor::wix:Directory/@Name'>
<xsl:value-of select="concat(.,'_')"/>
</xsl:for-each>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="Id">
<xsl:value-of select="/wix:Wix/wix:Fragment/wix:DirectoryRef/@Id"/>_<xsl:value-of select="translate($parentPath, '- ', '__')"/><xsl:value-of select="translate(@Name, '- ', '__')"/>
</xsl:attribute>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
_
_
这种方法不能保证Id的唯一性,但对我来说效果很好。我希望heat.exe能够像《WiX:Windows Installer XML开发人员指南》第2章中所建议的那样,在文件/@Id中包含父目录名。我保存了太多的文件,无法手动编写它们的ID。您可能可以通过使用XSLT来实现这一点。因为XSL转换可能非常复杂,所以需要做一些练习。:)我希望heat.exe能够像《WiX:Windows Installer XML开发人员指南》第2章中所建议的那样,在文件/@Id中包含父目录名。我保存了太多的文件,无法手动编写它们的ID。您可能可以通过使用XSLT来实现这一点。因为XSL转换可能非常复杂,所以需要做一些练习。:)谢谢你的好代码。:)它工作得很好,我为自己定制了它。谢谢你提供的好代码。:)它工作得很好,我为自己定制了它。