2016-12-14 111 views
1

使用的WiX工具集3.10,并试图创建快捷方式已收获与heat.exe实用程序的某些文件,如:如何创建由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 

我的问题:

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

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

回答

0

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

定义您DesktopFolder目录定义

<Directory Id="TARGETDIR" Name="SourceDir"> 
    ... 
    <Directory Id="DesktopFolder"/> 
    ... 
</Directory> 

然后有一个组件

<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>  
2

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元素。

相关问题