如何将SVN文件排除在使用heat(WiX)采集之外?

如何将SVN文件排除在使用heat(WiX)采集之外?,svn,xslt,wix,heat,Svn,Xslt,Wix,Heat,我不想重复现有的问题,但提供的答案不起作用: 下面是my.wxs的外观: <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Fragment> <DirectoryRef Id="SDKCONTENTDIR"> <Directory Id="dirE2EC21E8B765C611E918FB22F3072

我不想重复现有的问题,但提供的答案不起作用:

下面是my.wxs的外观:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="SDKCONTENTDIR">
<Directory Id="dirE2EC21E8B765C611E918FB22F30721D1" Name=".svn" />
<Directory Id="dir7DC42F44E7FE9E20277B180A353D0263" Name="bin" />
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="sdkContent">
<Component Id="cmp5E86312F0CA2C53B8173AECD6A428747" Directory="dirE2EC21E8B765C611E918FB22F30721D1" Guid="{E87F312D-9DA2-4A68-B6C5-BCE2FF90720C}">
<File Id="filB766A28A7577EB4311FD03CD707BC211" KeyPath="yes" Source="$(var.publishContentDir)\.svn\all-wcprops" />
</Component>
<Component Id="cmp6EF52B3E331F226299060D45F533DC07" Directory="dirE2EC21E8B765C611E918FB22F30721D1" Guid="{5EA6AB2D-20C3-4B07-8E0A-7C28135BE922}">
<File Id="fil83205196F05211A66F9D25A7A5496FBA" KeyPath="yes" Source="$(var.publishContentDir)\.svn\entries" />
</Component>

我使用此.xsl代码来排除:

<xsl:key name="svn-search" match="wix:Component[ancestor::wix:Directory/@Name = '.svn']" use="@Id" />
<xsl:template match="wix:Directory[@Name='.svn']" />
<xsl:template match="wix:Component[key('svn-search', @Id)]" />

但我得到了很多“错误48未解决的符号引用”错误,因为它没有删除所有子元素

想法?

您会得到“未解析符号”错误,因为您过滤掉了Component元素,但保留了ComponentRef元素的原样。因此,这些元素仍然是孤立的,并且引用缺少的组件元素。这会被WiX编译器捕获


正如您现在可能猜到的那样,过滤掉相应的ComponentRef元素。希望这能有所帮助。

以下是我的工作:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">

    <!-- Copy all attributes and elements to the output. -->
    <xsl:template match="@*|*">
        <xsl:copy>
            <xsl:apply-templates select="@*" />
            <xsl:apply-templates select="*" />
        </xsl:copy>
    </xsl:template>

    <xsl:output method="xml" indent="yes" />

    <!-- Create searches for the directories to remove. -->
    <xsl:key name="svn-search" match="wix:Directory[@Name = '.svn']" use="@Id" />
    <xsl:key name="tmp-search" match="wix:Directory[@Name = 'tmp']" use="@Id" />
    <xsl:key name="prop-base-search" match="wix:Directory[@Name = 'prop-base']" use="@Id" />
    <xsl:key name="text-base-search" match="wix:Directory[@Name = 'text-base']" use="@Id" />
    <xsl:key name="props-search" match="wix:Directory[@Name = 'props']" use="@Id" />

    <!-- Remove directories. -->
    <xsl:template match="wix:Directory[@Name='.svn']" />
    <xsl:template match="wix:Directory[@Name='props']" />
    <xsl:template match="wix:Directory[@Name='tmp']" />
    <xsl:template match="wix:Directory[@Name='prop-base']" />
    <xsl:template match="wix:Directory[@Name='text-base']" />

    <!-- Remove Components referencing those directories. -->
    <xsl:template match="wix:Component[key('svn-search', @Directory)]" />
    <xsl:template match="wix:Component[key('props-search', @Directory)]" />
    <xsl:template match="wix:Component[key('tmp-search', @Directory)]" />
    <xsl:template match="wix:Component[key('prop-base-search', @Directory)]" />
    <xsl:template match="wix:Component[key('text-base-search', @Directory)]" />

    <!-- Remove DirectoryRefs (and their parent Fragments) referencing those directories. -->
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('svn-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('props-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('tmp-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('prop-base-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('text-base-search', @Id)]]" />
</xsl:stylesheet>

我有同样的问题,找到了你的答案。但是,我不满意需要按名称指定.svn文件夹的子目录。如果.svn目录将来更改结构,或者如果我有一个名为tmp的目录,这可能会中断

当我对我的xml运行xsl时,我还注意到有一些分散的目录片段。作为强迫症患者,我想清理一下,我注意到heat.exe有一个“抑制碎片”的选项。实际效果是使目录标记实际上相互嵌套,这使得编写xsl文件更加容易

在从嵌套标记结构中删除.svn目录之后,我仍然有一个问题,即ComponentRefs指向的组件ID与其包含的目录一起被删除。作为一个XSLNoob,我不得不做一些挖掘,但发现我可以在xsl:key的use属性中使用“genderant::”

简而言之,这是我的解决方案。注意,我实际上还没有尝试用它来构建MSI;那将在一两天内到来。但即使它不是完美的,至少这可以帮助其他人解决同样的问题

用法:heat.exe dir source-t excludesvn.xsl-sfrag-o files.wxs



是的,存在孤立元素,但问题是我无法找到一种方法来过滤它们。Heat的.wxs中没有ComponentRef元素。事实上,正是由于顶级.svn目录被过滤掉,组件元素被孤立了。svn搜索似乎无法正常工作,但我无法确定原因。哇,对于“noob”来说,这很好,尤其是使用“svn搜索”键。好极了!哦,
与您的两行显式
应用模板
相同。对于
svn搜索
键,您也可以使用
。此XPath将wix:组件与名为“.svn”的wix:目录祖先相匹配。有关更多信息,请参阅。这帮助我创建了一个简单的转换来从目录中删除符号文件。我花了几个小时寻找,这是迄今为止我遇到的这个问题的最佳解决方案。对于在HeatDirectory任务中使用msbuild的任何其他人,请注意添加SuppressFragments=“true”等同于-sfrag参数。当.svn下面有子目录时,我对解决方案有问题。此外,不会删除ComponentRef。
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
  <!-- Copy all attributes and elements to the output. -->
  <xsl:template match="@*|*">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
      <xsl:apply-templates select="*" />
    </xsl:copy>
  </xsl:template>
  <xsl:output method="xml" indent="yes" />

  <!-- Search directories for the components that will be removed. -->
  <xsl:key name="svn-search" match="wix:Directory[@Name = '.svn']" use="descendant::wix:Component/@Id" />

  <!-- Remove directories. -->
  <xsl:template match="wix:Directory[@Name='.svn']" />

  <!-- Remove componentsrefs referencing components in those directories. -->
  <xsl:template match="wix:ComponentRef[key('svn-search', @Id)]" />
</xsl:stylesheet>