繁体   English   中英

Wix安装程序如何区分目标版本?

[英]How can the Wix Installer distinguish target builds?

我在Visual Studio中的C#项目将通过Wix安装。 我有两个目标版本:Demo和Release。 我想区分这些版本,并在产品名称后添加后缀“ Demo”:

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

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

我该如何工作?

使用以下代码,您可以基于Configuration MSBuild属性定义producttarget WiX变量:

<!-- 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">

我自己解决了。 我可以使用var.ProjectName.Configuration和Wix的预处理器来区分演示和发行版。

这是我的开关:

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

将后缀(Demo)添加到我的产品中:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM