2014-11-24 24 views
0

我的Visual Studio中的C#項目將通過Wix進行安裝。我有兩個目標構建:演示和發佈。我想區分這些構建和後綴「示範」增加了產品的名稱:Wix Installer如何區分目標版本?

#if Demo 
    <?define Suffix = "(Demo)"?> 
#endif 

<Product [...] Name="MyApp $(var.Suffix)" [...] > 

我怎樣才能讓工作呢?

回答

0

我通過我自己的解決方案。我可以使用var.ProjectName.Configuration和Wix的預處理器來區分演示和發佈。

這是我的開關:

<?if $(var.ProjectName.Configuration) = Demo ?> 
    <?define Suffix = "(Demo)" ?> 
<?else ?> 
    <?define Suffix = "" ?> 
<?endif ?> 

添加後綴(演示)到我的產品:

<Product [...] Name="MyApp $(var.Suffix)" [...] > 
2

用下面的代碼,你可以定義producttarget WiX的變量基於Configuration MSBuild的屬性:

<!-- Somewhere in .wixproj --> 
<PropertyGroup> 
    <DefineConstants Condition=" '$(Configuration)' == 'Debug' ">$(DefineConstants);producttarget= (Demo)</DefineConstants> 
    <DefineConstants Condition=" '$(Configuration)' == 'Release' ">$(DefineConstants);producttarget=</DefineConstants> 
</PropertyGroup> 

,然後在Product聲明中使用producttarget

<Product Id="*" 
     Name="SetupProject1$(var.producttarget)" 
     Language="1033" 
     Version="1.0.0.0" 
     Manufacturer="Manufacturer1" 
     UpgradeCode="41169d90-ca08-49bc-b87b-4b74f1f50d0e">