如何为heat.exe收集的文件创建快捷方式?

use*_*624 3 xslt wix heat

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

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

我的问题:

  1. 我现在知道我应该使用XSLT文件转换ProjFiles.wxs(该-t选件heat.exe),但具体的WiX的文档怎么写它是不存在的:是否有人可以提供,增加了一个例子一个Shortcut在桌面上为Id“Prog.exe”的?

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

Tom*_*get 5

记录了特定于WiX的信息,但是要学习足够的XSL有点挑战。这应该使您入门。您可能需要适应您的姓名,热度争论等。

<?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>
Run Code Online (Sandbox Code Playgroud)

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


Bri*_*and 0

这应该让它在桌面上创建一个快捷方式。您将收到 ICE 警告,因为该快捷方式与 Prog.exe 文件的组件不在同一组件中,但可以安全地忽略它(如果您将警告视为错误,请将 ICE 添加到“抑制特定 ICE 验证”列表中)。 (wixproj 属性 Visual Studio 中的工具设置<SuppressIces>。wixproj 中的标记。或者,cmd 行中的 -sice:ICE##)

在目录定义中定义您的 DesktopFolder

<Directory Id="TARGETDIR" Name="SourceDir">
    ...
    <Directory Id="DesktopFolder"/>
    ...
</Directory>
Run Code Online (Sandbox Code Playgroud)

然后有一个组件

<Component Id="ProgDesktopShortcut">
    <Shortcut
        Id="ProgDesktopShortcut"
        Directory="DesktopFolder"
        Target="[#Prog.exe]" 
        Name="Prog Shortcut"
        WorkingDirectory="INSTALLDIR" >
    </Shortcut>
    <RegistryValue  
        Id="ProgDesktopRegShortcut" 
        Root="HKCU" 
        Key="SOFTWARE\Prog\" 
        Name="ProgInstall" 
        Type="integer" 
        Value="1" 
        KeyPath="yes"/>    
</Component>    
Run Code Online (Sandbox Code Playgroud)