如何从WIX安装程序中排除web.config

时间:2013-07-15 13:38:20

标签: web-applications web-config wix

我正在为Web应用程序创建一个WIX设置。我使用设置wix add-in来快速完成此操作。但是如何从目录中排除web.config?

我不想在所有.config文件上使用过滤器,只需要在web.config上使用过滤器。感谢。

我创建了一个名为WebApplicationWix的测试项目。

1 个答案:

答案 0 :(得分:2)

在转换过滤器中更具体一点。请记住,过滤器是在SRC值上完成的。

E.g。 wix:Component [contains(wix:File / @ Source,' * .config ')]到wix:Component [contains(wix:File / @ Source,' $(var.HostFileDir) )\的Web.config ')]

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxl="urn:schemas-microsoft-com:xslt"
                exclude-result-prefixes="msxl"
                xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
  <xsl:strip-space elements="*" />

  <!-- Get harvest file details -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>

  <!-- Match and ignore Web.Config file-->
 <xsl:key name="config-search" match="wix:Component[contains(wix:File/@Source, '$(var.HostFileDir)\Web.config')]" use="@Id" />
  <xsl:template match="wix:Component[key('config-search', @Id)]" />
  <xsl:template match="wix:ComponentRef[key('config-search', @Id)]" />

</xsl:stylesheet>