这是我的预构建脚本:
"%WIX%binheat.exe" dir "$(SolutionDir)ExportReleaseSkyCamConfig" -t "$(SolutionDir)IQStudioInstallerSimulatorIgnore.xsl" -dr Simulator -srd -cg SimulatorComponentGroup -var var.SimulatorSourcePath -ag -sreg -out "$(SolutionDir)IQStudioInstallerIQStudioSimulatorDir.wxs"
是我的*。xsl文件:
<?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">
<xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<RemoveFolder Id="{@Id}" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" />
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
我遇到的问题是添加了xlmns属性,添加到my和:
xmlns = " " xmlns: wix = " http://schemas.microsoft.com/wix/2006/wi "
为什么要添加这个,我如何删除它?
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Simulator" />
</Fragment>
<Fragment>
<ComponentGroup Id="SimulatorComponentGroup">
<Component Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" Directory="Simulator" Guid="*">
<RemoveFolder Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" On="uninstall" **xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"** />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<File Id="fil763F3807501181AEBB3384E197DA1B60" KeyPath="yes" Source="$(var.SimulatorSourcePath)aeStatGridWeights.txt" />
</Component>
<Component Id="cmp9FA0A11B61A218ED2C433E82749C7264" Directory="Simulator" Guid="*">
<RemoveFolder Id="cmp9FA0A11B61A218ED2C433E82749C7264" On="uninstall" **xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"** />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<File Id="fil52CCB4416F79DAB20B21723321A693FD" KeyPath="yes" Source="$(var.SimulatorSourcePath)afStatGridWeights.txt" />
</Component>
更新:
我编辑我的*。像Tim建议的那样,它修复了一个问题
<?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"
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<RemoveFolder Id="{@Id}" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" />
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
现在输出为:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Simulator" />
</Fragment>
<Fragment>
<ComponentGroup Id="SimulatorComponentGroup">
<Component Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" Directory="Simulator" Guid="*">
<wix:RemoveFolder Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" On="uninstall" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<File Id="fil763F3807501181AEBB3384E197DA1B60" KeyPath="yes" Source="$(var.SimulatorSourcePath)aeStatGridWeights.txt" />
</Component>
<Component Id="cmp9FA0A11B61A218ED2C433E82749C7264" Directory="Simulator" Guid="*">
<wix:RemoveFolder Id="cmp9FA0A11B61A218ED2C433E82749C7264" On="uninstall" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
<File Id="fil52CCB4416F79DAB20B21723321A693FD" KeyPath="yes" Source="$(var.SimulatorSourcePath)afStatGridWeights.txt" />
</Component>
所以xmlns=""
消失了!
但是它并没有解决xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
问题在于这些行
<RemoveFolder Id="{@Id}" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" />
您在NO名称空间中输出元素,但是对于您的Wix文件,它们需要进入"http://schemas.microsoft.com/wix/2006/wi"名称空间。
您可以通过为元素
指定相关的名称空间前缀来轻松修复此问题。 <wix:RemoveFolder Id="{@Id}" On="uninstall" />
<wix:RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="string" Value="" KeyPath="yes" />
或者,您也可以将wix名称空间作为默认名称空间添加到XSLT
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns="http://schemas.microsoft.com/wix/2006/wi">
这样,没有名称空间前缀的元素将成为默认名称空间的一部分。