0
  I have created this xsl for dynamically create .WXS output.But i am facing one issue like  as per the below xsl it creates component group for each folder.I don't want to create component group for each folder and i need to have only one component group and add all the components into this group.
I have one component gruop  "HelpFiles_Group" as mentioned in the below output and it generates from heat.exe.I have added "extjs","css" folders manually within the same "HelpFiles_Group" group but i am expecting this should be part of XSL..

在使用下面的 xsl 时,它正在为“extjs”、“css”文件夹创建不同的组件组。知道如何将所有组件添加到同一个组件组中吗?下面的 XSL 需要进行哪些更改?

我的 XSL,

<xsl:stylesheet version="2.0"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="wix">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="wix:Wix">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
        <wix:Fragment>
          <wix:ComponentGroup Id="{@Name}">
            <xsl:if test="count(descendant::wix:Component) = 0">
              <wix:Component Id="{@Id}" Directory="{@Id}" Guid="">
                <wix:RemoveFolder Id="{@Name}" On="uninstall" />
                <!--<wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />-->
              </wix:Component>
            </xsl:if>
          </wix:ComponentGroup>
        </wix:Fragment>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:Component">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()" />
      <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="SimCentral" KeyPath="yes" xmlns="http://schemas.microsoft.com/wix/2006/wi"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:File">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="KeyPath">
        <xsl:text>no</xsl:text>
      </xsl:attribute>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

预期输出 .WXS。

<Fragment>
    <DirectoryRef Id="Simulation_Help">
      <Directory Id="extjs" Name="extjs" />
      <Directory Id="images_1" Name="images" />
      <Directory Id="uilocale" Name="uilocale" />
    </DirectoryRef>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="HelpFiles_Group">

      <Component Id="extjs" Guid="{8FB704ED-5A08-42DF-A593-8F04AD8EAB64}" Directory="extjs">
        <RemoveFolder Id="SimSciHelp_extjs" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="css" Guid="{A5066974-3279-4C45-85EA-F3A7F55343C4}" Directory="css">
        <RemoveFolder Id="css" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="default" Guid="{BF114032-02E5-49B1-A8FD-F927843A5E7A}" Directory="default">
        <RemoveFolder Id="default" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="button" Guid="{42BE8034-622B-4C76-8FA1-78DDD151037C}" Directory="button">
        <RemoveFolder Id="button" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

根据新 XSL 输出

        <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="Simulation_Help">
      <wix:Component Id="extjs" Directory="extjs" Guid="">
        <wix:RemoveFolder Id="extjs" On="uninstall" />
      </wix:Component>
      <wix:Component Id="images_1" Directory="images_1" Guid="">
        <wix:RemoveFolder Id="images" On="uninstall" />
      </wix:Component>
      <wix:Component Id="uilocale" Directory="uilocale" Guid="">
        <wix:RemoveFolder Id="uilocale" On="uninstall" />
      </wix:Component>
    </wix:ComponentGroup>
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="uilocale" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="images_1" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="tree" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="toolbar" />

它不应该创建单独的组件组,而是所有组件 id 都应该在第一个组件组中。

4

1 回答 1

0

我认为您遇到的问题是您正在xsl:for-each中创建wix :ComponentGroup元素

  <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
    <wix:Fragment>
      <wix:ComponentGroup Id="{@Name}">

对于每个wix:DirectoryRef ,您真的只需要一个wix:ComponentGroup ,这意味着您可能需要两个嵌套的 xsl:for-each语句,一个用于wix:DirectoryRef,一个嵌套在内部用于wix:Directory

尝试这样的事情

<xsl:template match="wix:Wix">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    <xsl:for-each select="wix:Fragment/wix:DirectoryRef">
      <wix:Fragment>
        <wix:ComponentGroup Id="{@Id}">
          <xsl:for-each select="wix:Directory">
             <xsl:if test="count(descendant::wix:Component) = 0">
               <wix:Component Id="{@Id}" Directory="{@Id}" Guid="">
                 <wix:RemoveFolder Id="{@Name}" On="uninstall" />
                 <!--<wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />-->
               </wix:Component>
             </xsl:if>
           </xsl:for-each>
        </wix:ComponentGroup>
      </wix:Fragment>
    </xsl:for-each>
  </xsl:copy>
</xsl:template>
于 2013-07-09T07:37:08.977 回答