如何使用XSLT从另一个wxs文件中筛选重复项 我所拥有的
我在使用xslt查找重复组件时遇到问题。 我用热收获2个项目。这些项目共享一些引用(.dll文件)。现在热量产生2个碎片如何使用XSLT从另一个wxs文件中筛选重复项 我所拥有的,xslt,wix,windows-installer,heat,Xslt,Wix,Windows Installer,Heat,我在使用xslt查找重复组件时遇到问题。 我用热收获2个项目。这些项目共享一些引用(.dll文件)。现在热量产生2个碎片 <!--Match and ignore .pdb files--> <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" /> <xsl:template match="wix:Compon
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
首先创建ConfiguratorFiles.wxs并使用totaly basic筛选器:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
输出是完全好的,因为我真的希望每个dll被复制并过滤掉pdb文件
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
创建ServiceFiles.wxs文件时会出现问题。我只是不知道如何检查第一个wxs文件中是否存在元素
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
link提供了信息,我可以嵌入一个C#函数来执行一些逻辑。这对我来说似乎是一个巧妙的技巧,但我仍然不知道如何搜索另一个文件的内容
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
当前ServiceFilter.xslt
ServiceFilter.xslt与ConfiguratorFiles.xslt几乎相同,但在手动处理.exe文件时,我也会过滤掉它们
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
例子:
我有以下两个组件(ConfiguratorFiles.wxs和ServiceFiles.wxs)。这会导致一个错误,这就是为什么我需要过滤重复项
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
<Component Id="Foo.Base.dll" Guid="*">
<File Id="Foo.Base.dll" KeyPath="yes" Source="$(var.Foo.DSI.Configurator.TargetDir)\Foo.Base.dll" />
</Component>
实际问题
如何编写过滤器“ServiceFilter.xslt”来过滤重复项,以便ServiceFiles.wxs不包含ConfiguratorFiles.wxs中包含的文件
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
更新
我现在尝试的是使用C#方法。
现在我只需要弄清楚,如何让第一个文件中的所有组件填写FindDuplicate方法,因为它目前过滤所有内容:)
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
解决方案非常简单
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>
我现在创建了两个单独的MSI文件。一个安装configurator,另一个安装服务。
这两个MSI文件是在两个不同的WiX项目中创建的,因此不会再出现重复条目的问题。您似乎正在获取整个生成输出文件夹,并使用heat.exe和MSBuild/Visual Studio。生成输出文件夹主要用于在生成计算机上进行调试。这是一种特殊情况,整个构建输出文件夹都适合安装。尝试使用MSBuild with仅获取主项目输出(“二进制文件”)。感谢您的提示。仅获取主要项目似乎更准确,但我担心这不会解决问题,在我将2个相同的dll获取到2个不同的片段后,WiX在构建时抛出错误
<!--Match and ignore .pdb files-->
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]"/>
<!--Match and ignore .exe files-->
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.exe')]" use="@Id"/>
<xsl:template match="wix:Component[key('exe-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]"/>