2014-11-24 80 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">