2012-01-05 29 views
6

私は事実上、既存の質問を複製することを憎むが、供給の答えは働いていない:私はこれを使用しています...SVNファイルを除熱(WiX)から除外する方法はありますか?

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

:ここに私の.wxsは次のようになります

を除外するの.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未解決の参照」エラーを取得しています要素。

アイデア?

答えて

4

は、私が働いて得たものである:

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

.svnの下にサブディレクトリがあるとき、私は解決策に問題がありました。また、ComponentRefsは削除されません。 – tofutim

0

コンポーネント要素を除外してComponentRef要素をそのまま残しているため、「未解決シンボル」エラーが表示されます。したがって、これらの要素は孤立したままであり、参照要素が欠落しています。これはWiXコンパイラによって捕捉されます。

これまでに推測したように、対応するComponentRef要素もフィルタ処理します。お役に立てれば。ここで

+0

孤立した要素がありますが、問題を解決する方法がありません。 Heatの.wxにはComponentRef要素はありません。実際には、トップレベルの.svnディレクトリが除外されているため、孤立しているコンポーネント要素です。 svn-searchは正常に動作していないように見えますが、理由を判断できません。 – jbierling

19

私は同じ質問があったが、あなたの答えを見つけました。しかし、私は名前で.svnフォルダのサブディレクトリを指定する必要性に不満を抱いていました。これは将来、.svnディレクトリの構造が変更された場合や、目的のためにtmpという名前のディレクトリがある場合に壊れる可能性があります。

xslを自分のxmlに対して実行したとき、まわり。 OCDであり、それをきれいにしたいと思って、私はheat.exeが "断片を抑制する"オプションを持っていることに気づいた。実際の効果は、ディレクトリタグを実際に互いにネストさせることで、xslファイルの書き込みがはるかに簡単になりました。

ネストされたタグ構造から.svnディレクトリを削除した後も、ComponentRefsが含まれているコンポーネントIDを指しているという問題がありました。自分でxsl noobであるので、ちょっと掘り下げなくてはなりませんでしたが、xsl:keyのuse属性に "descendant ::"を使用できることがわかりました。

要するに、ここに私の解決策があります。私は実際にまだMSIを構築しようとしていないことに注意してください。それは1日か2日で来るでしょう。しかし、それは完璧ではない場合でも、少なくともこれは同じ問題で他の誰かを助けるかもしれない...

用途:heat.exe DIRソース-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> 
+1

うわー、 "noob"のために、これは特に "svn-search"キーを使ってうまくいきます。ブラボー!ああ、 ''はあなたの2つの明示的な 'apply-templates'行と同じです。 –

+1

解決策はすぐにあります。 -ffragがキーです。 – tofutim

+0

'svn-search'キーでは、' 'このXPathはwix:Componentとwix:Directory祖先の名前が '.svn'という名前で一致します。詳細については、[XPath構文](http://msdn.microsoft.com/en-us/library/ms256471(v = vs.85).aspx)を参照してください。 – MageWind

関連する問題