2012-01-05 32 views
6

Tôi ghét phải thực tế lặp lại câu hỏi hiện có, nhưng câu trả lời cung cấp chưa từng làm việc:Làm cách nào để loại trừ các tệp SVN khỏi thu hoạch bằng nhiệt (WiX)?

Đây là những gì .wxs của tôi trông giống như:

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

...

Tôi đang sử dụng này .xsl mã để loại trừ:

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

Nhưng tôi nhận được nhiều lỗi "Lỗi 48 Tham chiếu đến biểu tượng chưa được giải quyết" vì nó không xóa tất cả con các yếu tố.

Ý tưởng?

Trả lời

4

Dưới đây là những gì tôi đã làm việc:

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

Tôi gặp vấn đề với giải pháp khi có các thư mục con bên dưới .svn. ComponentRef cũng không bị loại bỏ. – tofutim

0

Bạn gặp lỗi "biểu tượng chưa được giải quyết" vì bạn lọc ra các thành phần Thành phần, nhưng để nguyên tố ComponentRef như cũ. Do đó, những yếu tố đó vẫn còn mồ côi và tham chiếu các thành phần thiếu Thành phần. Điều này bị bắt bởi trình biên dịch WiX.

Như bạn có thể đoán bây giờ, lọc ra các thành phần ComponentRef tương ứng. Hi vọng điêu nay co ich.

+0

Vâng, có những yếu tố mồ côi, nhưng vấn đề là tôi không thể tìm cách lọc chúng ra. Không có phần tử ComponentRef trong các tệp .wx của Heat. Đó là trong thực tế, các yếu tố thành phần đang được mồ côi kể từ khi thư mục .svn cấp cao nhất đang được lọc ra. Các svn-tìm kiếm dường như không hoạt động đúng nhưng tôi không thể xác định lý do tại sao. – jbierling

19

Tôi có cùng một câu hỏi, và tìm thấy câu trả lời của bạn. Tuy nhiên, tôi đã không hài lòng với sự cần thiết phải xác định các thư mục con của thư mục .svn theo tên. Điều này có thể phá vỡ nếu thư mục .svn thay đổi cấu trúc trong tương lai hoặc nếu tôi có thư mục có tên tmp có chủ đích ...

Khi tôi chạy xsl của bạn dựa vào xml, tôi cũng nhận thấy rằng có một số đoạn thư mục nằm rải rác xung quanh. Là OCD và muốn dọn dẹp nó, tôi nhận thấy rằng heat.exe có một tùy chọn để "chặn các mảnh". Hiệu quả thực tế là làm cho các thẻ Directory thực sự lồng nhau, điều này làm cho việc viết một tệp xsl dễ dàng hơn nhiều.

Sau khi xóa thư mục .svn khỏi cấu trúc thẻ lồng nhau, tôi vẫn gặp sự cố với ComponentRef trỏ đến ID thành phần đã bị xóa cùng với thư mục chứa của chúng. Là một xsl noob bản thân mình, tôi đã phải làm một chút đào, nhưng thấy rằng tôi có thể sử dụng "hậu duệ ::" trong thuộc tính sử dụng của xsl: key.

Tóm lại, đây là giải pháp của tôi. Lưu ý, tôi chưa thực sự cố gắng để xây dựng MSI với nó chỉ được nêu ra; sẽ đến trong một hoặc hai ngày. Nhưng ngay cả khi nó không phải là hoàn hảo, ít nhất điều này có thể giúp đỡ người khác với cùng một vấn đề ...

Sử dụng: heat.exe nguồn 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

Chà, vì một "noob", điều này rất tốt, đặc biệt là sử dụng khóa 'svn-search'. Bravo! Oh, '' giống như hai dòng 'apply-templates' rõ ràng của bạn. –

+1

Giải pháp là đúng. -sfrag là chìa khóa. – tofutim

+0

Đối với khóa 'svn-search', bạn cũng có thể sử dụng' '. XPath này khớp với wix: Component with a wix: Tổ tiên thư mục có tên '.svn'. Xem [Cú pháp XPath] (http://msdn.microsoft.com/en-us/library/ms256471 (v = vs.85) .aspx) để biết thêm thông tin. – MageWind

Các vấn đề liên quan