2016-12-14 122 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元素。

相關問題