如何从热 (WiX) 收获中排除 SVN 文件?

发布于 2024-12-25 08:51:36 字数 1428 浏览 2 评论 0原文

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

这是我的 .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 未解决的参考”符号”错误,因为它没有删除所有子元素。

有想法吗?

I hate to practically duplicate existing questions, but the supplied answers haven't worked:

Here's what my .wxs looks like:

<?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>

...

I'm using this .xsl code to exclude:

<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)]" />

But I'm getting many "Error 48 Unresolved reference to symbol" errors as its not removing all child elements.

Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寻梦旅人 2025-01-01 08:51:36

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

当我针对我的 xml 运行 xsl 时,我还注意到周围散布着一些目录片段。由于强迫症并想要清理它,我注意到 heat.exe 有一个“抑制碎片”的选项。实际效果是使 Directory 标记实际上相互嵌套,这使得编写 xsl 文件变得更加容易。

从嵌套标签结构中删除 .svn 目录后,我仍然遇到 ComponentRefs 指向组件 ID 的问题,这些组件 ID 及其包含的目录已被删除。作为一名 xsl 菜鸟,我不得不进行一些挖掘,但发现我可以在 xsl:key 的 use 属性中使用“descendant::”。

简而言之,这是我的解决方案。请注意,我实际上还没有尝试用它构建 MSI;一两天后就会出现。但即使它并不完美,至少这可能会帮助其他遇到同样问题的人...

使用:heat.exe dir source -t exceptsvn.xsl -sfrag -o files.wxs

<?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>

I had the same question, and found your answer. However, I was unhappy with the need to specify the subdirectories of the .svn folder by name. This can break if the .svn directory changes structure in the future, or if I had a directory named tmp on purpose...

When I ran your xsl against my xml, I additionally noticed that there were some directory fragments scattered around. Being OCD and wanting to clean that up, I noticed that heat.exe has an option to "suppress fragments". The actual effect was to make Directory tags actually nest under each other, which makes writing an xsl file much easier.

After deleting .svn directories from the nested tag structure, I still had a problem with ComponentRefs pointing to Component IDs that had been removed along with their containing directories. Being an xsl noob myself, I had to do a little digging, but found that I could use "descendant::" in the use attribute of xsl:key.

In short, here is my solution. Note, I have not actually yet tried to build the MSI with it just yet; that will come in a day or two. But even if it isn't perfect, at least this might help someone else with the same problem...

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

<?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>
小霸王臭丫头 2025-01-01 08:51:36

这是我的工作内容:

<?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>

Here is what I got working:

<?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>
云淡风轻 2025-01-01 08:51:36

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

正如您现在可能已经猜到的,还要过滤掉相应的 ComponentRef 元素。希望这有帮助。

You get the "unresolved symbol" error because you filter out the Component elements, but leave the ComponentRef elements as is. Hence, those elements remain orphaned and reference missing Component elements. This gets caught by the WiX compiler.

As you probably guessed by now, filter out the corresponding ComponentRef elements as well. Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文