2012-07-02 25 views
2

理想情況下,我會從項目規格本身獲取輸出,但heat.exe似乎不支持contentproj文件作爲項目類型,如果我傳入遊戲的主要csproj,它也不會提取內容。如何使用WiX來收集XNA內容文件?

目前我有一個預先構建的步驟調用輸出文件夾的熱量,但(a)會感覺髒,並且(b)會產生一堆引用相對於輸出文件夾的源路徑的File標記,例如當它無法找到它們相對於WiX項目的文件夾時,構建失敗。

我要指出,我使用還願和我的項目佈局是這樣的:

- Main solution 
- XNA "Metaproject" Folder 
    - Game 
    - bin/x86/Release (GameContent output appears here) 
    - GameContent 
- WiX Project 

我非常希望儘量減少次我必須指定像"../../Game/Game/bin/x86/Release/Content"路徑的數量,因爲這是容易出錯並且壓抑以輸出。在正確的方向刺激讚賞!

回答

2

假設contentproj只是一個文件的集合,你可以做的是直接被創建安裝程序的wixproj中添加的收穫:

<PropertyGroup> 
    <HarvestDirectoryNoLogo>true</HarvestDirectoryNoLogo> 
    <HarvestDirectorySuppressFragments>true</HarvestDirectorySuppressFragments> 
    <HarvestDirectorySuppressUniqueIds>true</HarvestDirectorySuppressUniqueIds> 
    <HarvestDirectoryAutogenerateGuids>true</HarvestDirectoryAutogenerateGuids> 
</PropertyGroup> 
<ItemGroup> 
    <HarvestDirectory Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' " 
         Include="$(SolutionDir)\GameContent"> 
     <DirectoryRefId>INSTALLDIR</DirectoryRefId> 
     <SuppressRootDirectory>true</SuppressRootDirectory> 
     <PreprocessorVariable>var.GameContentDir</PreprocessorVariable> 
     <ComponentGroupName>GameContent</ComponentGroupName> 
    </HarvestDirectory>  
</ItemGroup> 

您需要手動添加此到wixproj文件如果您需要多個目錄,您可以爲每個目錄重複HarvestDirectory。

要設置var.GameContentDir預處理器變量編輯DefineConstants屬性:

<DefineConstants>GameContentDir=$(GameContentDir);</DefineConstants> 

將預處理器VAR設置爲MSBuild的屬性:

<GameContentDir>$(SolutionDir)\GameContent</GameContentDir> 

這意味着,你可以修改這取決於構建配置。如果您不需要修改路徑,只需在<DefineConstants>屬性中設置一個靜態值即可。

然後,這將生成一個wxs文件在每個構建obj目錄,然後包含假設您已包含ComponentGroupName。如果你已經包含了你之前在你的wixproj中生成的那個,那麼將它刪除,因爲如果ComponentGroupName是相同的,你將會發生衝突。