wix windows add a service component in the use of heat to automatically generate wxs

Recently needed to add a windows installer service component, as I understand it, I think just adding the following paragraph Product.wxs label on it
1 <Componet Id="myservice">
2     <File Id="Service.exe" KeyPath="yes" Source="{Service.exe路径}">
3     <ServiceInstall Id="Installer" DisplayName="MyService" Name="MyService"/>
4     <ServiceControl Id="Control" Name="MyService" Start="install" Stop="both" Remove="uninstall"/>
5 </Componet>

 

But because my project components are included automatically generate the corresponding wxs file by Heat.exe, and Service.wxs the generation which already contains Service.exe I need to reference above. At this point I would add on top of this label, it will be repeated because Service.exe cited two File tags can not be generated.

 

Charles circle finally found a solution, let me Service.exe special treatment when heat is generated, that is, modify Filter.xslt, add the following label
  <xsl:template match="wix:Component[contains(wix:File/@Source, 'Service.exe') and not(contains(wix:File/@Source, 'Service.exe.config'))]">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
        <wix:ServiceInstall Id="Installer" DisplayName="MyService" Name="MyService"/>
        <wix:ServiceControl Id="Control" Name="MyService" Start="install" Stop="both" Remove="uninstall"/>
    </xsl:copy>
  </xsl:template>

 

As a result, when the Heat generated wxs, the label will be attached ServiceInstall services such as installation of Windows in a match files that Service.exe the Component.

 

PS: If exist within the assembly .exe and .exe.config words, match conditions require increased as above a not (contains (wix: File / @ Source, 'Service.exe.config'))], otherwise it will generate when because the heat to the two files are assigned the same label can not ServiceInstall subsequent processing. If this condition is not .exe.config you do not need a

Guess you like

Origin www.cnblogs.com/GenyouNoChou/p/12160285.html