我有一個非常大的安裝程序工具包來構建Visual Studio 2013(包括一些與主項目相關的工具,Windows服務和具有非平凡目錄結構的Web應用程序)。我仍然在學習如何使用WiX,並且仍在制定,測試和改進WiX項目。目前,我使用格式爲
「C:\ Program Files(x86)\ WiX Toolset v3.9 \ bin \ heat.exe」dir「$(SolutionDir)的命令將收穫任務設置爲構建事件)\ MyProjectDir \ bin \ $(ConfigurationName)「-cg MyComponentRef -ag -dr MYINSTALLDIR -srd -wixvar -var var.MySourceFiles -sreg -out」$(SolutionDir)\ Deployment \ My Installer Project \ ComponentList.wxs「-t 「$(SolutionDir)\ Deployment \ My Installer Project \ FileFilter.xslt」
此命令只抓取項目bin \ Debug(或bin \ Release)文件夾中的所有文件,然後使用xml樣式錶轉換對其進行過濾。這樣收集的收穫不少,因此保持所有源文件變量(命令中的「var.MySourceFiles」參數)變得單調乏味且容易出錯。最初,我已經將這些聲明添加到項目的預處理器變量中,但我想要一些更「自包含」的東西。使用有用的提示,我發現在WiX tricks and tips,我宣佈一個新的包含文件,「PreprocessorVars.wxi」與內容
,並得到了XSLT將其包含在由熱產生的輸出。
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<?include
$(sys.CURRENTDIR)\PreprocessorVars.wxi
?>
<Fragment>
<DirectoryRef Id="MYINSTALLDIR" />
</Fragment>
<Fragment>
<ComponentGroup Id="MyComponentRef">
<Component Id="xyz" Directory="MYINSTALLDIR" Guid="*">
<File Id="abc" KeyPath="yes" Source="$(var.MySourceFiles)\MyProjectExecutable.exe" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
其維克斯處理沒有任何錯誤:與片段
<xsl:processing-instruction name="include">
$(sys.CURRENTDIR)\PreprocessorVars.wxi
</xsl:processing-instruction>
的XSLT現在產生的輸出看起來像這樣的EXE。
我發現這是答案:http://stackoverflow.com/a/4280454/11421 – 2012-05-12 04:58:18