如何系统地将“ReadOnly”属性设置为使用热量收获的文件?

时间:2012-01-12 18:56:11

标签: wix wix3 heat

我正在使用heat收集一个目录,但是,我无法找到一个选项来设置所有文件使用heat收获的“ReadOnly”属性。

有没有人知道如何在高温下做这件事?

1 个答案:

答案 0 :(得分:4)

将XSLT变换应用于由heat生成的片段,并将ReadOnly="yes"添加到每个File元素。这个XSLT做了这件事:

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

    <xsl:template match="wix:File">
        <xsl:copy>
            <xsl:apply-templates select="@*" />
            <xsl:attribute name="ReadOnly">
                <xsl:text>yes</xsl:text>
            </xsl:attribute>
            <xsl:apply-templates select="*" />
        </xsl:copy>
    </xsl:template>

    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates select="@*" />
            <xsl:apply-templates select="* | text()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="@* | text()">
        <xsl:copy />
    </xsl:template>

    <xsl:template match="/">
        <xsl:apply-templates />
    </xsl:template>

</xsl:stylesheet>