如何创建Heat.exe收集的文件的快捷方式? [英] How to create shortcuts to files harvested by heat.exe?

查看:117
本文介绍了如何创建Heat.exe收集的文件的快捷方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WiX Toolset 3.10,并尝试为使用 heat.exe 实用工具收集的某些文件创建快捷方式,例如:

Using WiX Toolset 3.10, and trying to create shortcuts to certain files that have been harvested with the heat.exe utility, as by:

"%WIX%\bin\heat.exe" dir SourceDir -nologo -platform x64 ^
-ke -gg -g1 -suid -srd -scom -sreg -dr INSTALLDIR ^
-cg ProjFiles -out ProjFiles.wxs

我的问题:

  1. 我现在知道我应该使用XSLT文件来转换 ProjFiles.wxs ( heat.exe 中的-t选项)但是不存在有关如何编写它的特定于WiX的文档:有人可以提供一个示例,为Id"Prog.exe"在桌面上添加Shortcut吗?

  1. I know by now that I'm supposed to use an XSLT file to transform ProjFiles.wxs (the -t option in heat.exe) but WiX-specific documentation on how to write it is non-existent: can someone please provide an example that adds a Shortcut on the Desktop for an Id of "Prog.exe"?

由于-g1标志,共享相同基名的文件(例如"SourceDir \ dirA \ file.txt"和"SourceDir \ dirZ \ file.txt")将共享相同的Id(即"file.txt");为什么没有冲突,看到.MSI如何构建和运行正常?

Because of the -g1 flag, files which share the same basename (e.g. "SourceDir\dirA\file.txt" and "SourceDir\dirZ\file.txt") will share the same Id (i.e. "file.txt"); how come this isn't a conflict, seen how the .MSI builds and runs OK?

推荐答案

已记录了特定于WiX的信息,但要学习足够的XSL则是一个挑战.这应该可以帮助您入门.您可能必须适应您的姓名,热度争论等.

The WiX-specific information is documented but learning just enough XSL is a bit of a challenge. This should get you started. You might have to adapt to your names, heat arguments, etc.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:str="http://xsltsl.org/string"
  exclude-result-prefixes="wix str"  
  >

  <xsl:output
    encoding="utf-8"
    method="xml"
    version="1.0"
    indent="yes"    
    />

  <xsl:template match='wix:Component[contains(wix:File/@Source, "SourceDir\Prog.exe")]'> 
    <!-- assumes there is only one Prog.exe -->
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <xsl:comment> added shortcut under Component with File that has Source with Prog.exe </xsl:comment>
      <!-- Elsewhere, have an Icon element like: <Icon Id="Prog.exe" SourceFile="$(var.BUILDCACHE)Bin/Prog.exe" />  -->
      <Shortcut 
        Id="ProgExeShortcut" 
        Name="Prog Application" 
        Icon="Prog.exe" 
        Directory="ProgramMenuFolder_ProgVendor" 
        Advertise="yes">
        <xsl:attribute name="WorkingDirectory"><xsl:value-of select="@Directory"/></xsl:attribute>
      </Shortcut>
      <RemoveFolder 
        Id="ProgExeShortcut_ProgramMenuFolder_ProgVendor"  
        Directory="ProgramMenuFolder_ProgVendor" 
        On="uninstall" />
    </xsl:copy>
  </xsl:template>

    <!-- identity template -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match='/'>
    <xsl:comment>*** DO NOT EDIT: Generated by heat.exe; transformed by ProgComponentGroup.xsl</xsl:comment>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:template>

</xsl:stylesheet>

更具体和更早的模板在更通用或更晚的模板之前匹配.因此,基本操作是按原样复制每个元素,属性,文本和注释,除了要更改的元素,属性,文本和注释.对于要更改的内容,您可以重建所有内容,在这种情况下,将复制Component元素拥有的所有内容,然后添加Shortcut和RemoveFolder元素.

More specific and earlier templates match before more general or later ones. So, the base is to copy every element, attribute, text and comment AS IS, except the ones you want to change. For the ones you want to change, you reconstruct everything—in this case by copying everything the Component element had and then adding the Shortcut and RemoveFolder elements.

这篇关于如何创建Heat.exe收集的文件的快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆