gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:22:01 26 4
gpt4 key购买 nike

使用 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

我的问题:
  • 我现在知道我应该使用 XSLT 文件来转换 ProjFiles.wxs(heat.exe 中的 -t 选项),但是关于如何编写它的特定于 WiX 的文档不存在:有人可以提供添加 Shortcut 的示例在桌面上查看 Id “Prog.exe”?
  • 因为 -g1标志,共享相同基本名称的文件(例如“SourceDir\dirA\file.txt”和“SourceDir\dirZ\file.txt”)将共享相同的Id (即“file.txt”);为什么这不是冲突,看到 .MSI 如何构建和运行正常?
  • 最佳答案

    特定于 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>

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

    关于xslt - 如何为 heat.exe 收集的文件创建快捷方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41140034/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com