【发布时间】:2020-02-13 22:34:44
【问题描述】:
我有以下来源:
<DirectoryRef Id="INSTALLDIR">
<Component Id="Groupacuthin.exeAutoUpdate_acuthin.exe" Guid="*" Win64="no">
<File Id="Groupacuthin.exeAutoUpdate_acuthin.exe" KeyPath="yes" Source="$(var.HARVESTDIR)\Groupacuthin.exeAutoUpdate\acuthin.exe" />
</Component>
</DirectoryRef>
我有以下模板,它可以找到 ID 为“INSTALLDIR”的所有 DirectoryRef,并且有一个 ID 为“Groupacuthin.exeAutoUpdate_acuthin.exe”的组件,并将 DirectoryRef Id 从“INSTALLDIR”更改为“TARGETDIR”:
<xsl:template match="wix:DirectoryRef[@Id='INSTALLDIR' and wix:Component/@Id='Groupacuthin.exeAutoUpdate_acuthin.exe']">
<xsl:copy>
<xsl:attribute name="Id">TARGETDIR</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
这是正确的结果:
<DirectoryRef Id="TARGETDIR">
<Component Id="Groupacuthin.exeAutoUpdate_acuthin.exe" Guid="*" Win64="no">
<File Id="Groupacuthin.exeAutoUpdate_acuthin.exe" KeyPath="yes" Source="$(var.HARVESTDIR)\Groupacuthin.exeAutoUpdate\acuthin.exe" />
</Component>
</DirectoryRef>
如果我的来源有多个 DirectoryRefs,其组件 ID 如下所示:
<Component Id="Groupacuthin.exeAutoUpdate_acuthin.exe" Guid="*" Win64="no">
<Component Id="Groupfile1.exeAutoUpdate_file1.exe" Guid="*" Win64="no">
<Component Id="Groupfile2.exeAutoUpdate_file2.exe" Guid="*" Win64="no">
有没有办法更改模板以匹配任何具有 Id 且 Id 包含子字符串“AutoUpdate”的组件?
【问题讨论】: