xml – WiX安装程序:使用xslt with heat.exe来更新属性

前端之家收集整理的这篇文章主要介绍了xml – WiX安装程序:使用xslt with heat.exe来更新属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为 Windows服务创建一个WiX安装程序,并且我已经阅读了我的所有文件,将keyPath设置为“否”,但WiX脚本中的.exe除外.
我目前正在使用Heat.exe生成我的目录和文件结构,这里是我的命令:
  1. "$(WIX)bin\heat.exe" dir $(SolutionDir)EmailGenerationService\bin\PROD
  2. -cg EmailGenFiles -gg -scom -sreg -sfrag -srd -suid
  3. -dr INSTALLLOCATION -var var.FileSource
  4. -t $(Projectdir)KeyPathTransform.xslt
  5. -out $(ProjectDir)DirectoryAndFileComponents.wxs

我打算用我的DirectoryAndFileComponents.wxs文件中的Keypath =“no”更新所有文件元素.
热量输出的样本是:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  3. <Fragment>
  4. <DirectoryRef Id="INSTALLLOCATION">
  5. <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
  6. <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" />
  7. </Component>
  8. <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
  9. <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" />
  10. </Component>
  11. <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
  12. <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" />
  13. </Component>
  14. <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
  15. <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" />
  16. </Component>

这是XSLT,我正在热身子进行转型:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  5. exclude-result-prefixes="msxsl"
  6. xmlns:wix="http://schemas.microsoft.com/wix/2006/wix"
  7. xmlns:my="my:my">
  8.  
  9. <xsl:output method="xml" indent="no"/>
  10.  
  11. <xsl:strip-space elements="*"/>
  12.  
  13. <xsl:template match="@*|node()">
  14. <xsl:copy>
  15. <xsl:apply-templates select="@*|node()"/>
  16. </xsl:copy>
  17. </xsl:template>
  18.  
  19. <xsl:template match='/wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id="EmailGenerationService.exe")]'>
  20. <xsl:attribute name="KeyPath">
  21. <xsl:value-of select="no"/>
  22. </xsl:attribute>
  23. </xsl:template>
  24. </xsl:stylesheet>

我已经尝试了相当多的这个基于其他帖子在这个网站上的变体,而在哪里,但仍然无法获取由hot.exe创建的文件,以使KeyPath =“否”.

我错过了什么吗?

你有不同的定义的命名空间:

>在XML中:_ http://schemas.microsoft.com/wix/2006/wi
>在XSLT中:http://schemas.microsoft.com/wix/2006/wix

据我所知,WiX的正确命名空间是http://schemas.microsoft.com/wix/2006/wi.所以你应该纠正你的XSLT.

XSLT:

  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  4. exclude-result-prefixes="msxsl"
  5. xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  6. xmlns:my="my:my">
  7.  
  8. <xsl:output method="xml" indent="yes" />
  9.  
  10. <xsl:strip-space elements="*"/>
  11.  
  12. <xsl:template match="@*|node()">
  13. <xsl:copy>
  14. <xsl:apply-templates select="@*|node()"/>
  15. </xsl:copy>
  16. </xsl:template>
  17.  
  18. <xsl:template match='wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id = "EmailGenerationService.exe")]'>
  19. <xsl:copy>
  20. <xsl:apply-templates select="@*"/>
  21. <xsl:attribute name="KeyPath">
  22. <xsl:text>no</xsl:text>
  23. </xsl:attribute>
  24. </xsl:copy>
  25. </xsl:template>
  26. </xsl:stylesheet>

输入XML:

  1. <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  2. <Fragment>
  3. <DirectoryRef Id="INSTALLLOCATION">
  4. <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
  5. <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" />
  6. </Component>
  7. <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
  8. <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" />
  9. </Component>
  10. <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
  11. <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" />
  12. </Component>
  13. <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
  14. <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" />
  15. </Component>
  16. </DirectoryRef>
  17. </Fragment>
  18. </Wix>

输出XML:

  1. <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  2. <Fragment>
  3. <DirectoryRef Id="INSTALLLOCATION">
  4. <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
  5. <File Id="Dollar.Common.dll" Source="$(var.FileSource)\Dollar.Common.dll" KeyPath="no" />
  6. </Component>
  7. <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
  8. <File Id="Dollar.Common.Exceptions.dll" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" KeyPath="no" />
  9. </Component>
  10. <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
  11. <File Id="Dollar.Common.Exceptions.pdb" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" KeyPath="no" />
  12. </Component>
  13. <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
  14. <File Id="Dollar.Common.Logging.dll" Source="$(var.FileSource)\Dollar.Common.Logging.dll" KeyPath="no" />
  15. </Component>
  16. </DirectoryRef>
  17. </Fragment>
  18. </Wix>

猜你在找的XML相关文章