Simon
Simon

Reputation: 4794

How can the Wix Installer distinguish target builds?

My C# project in Visual Studio will be installed via Wix. I have two target builds: Demo and Release. I want to distinguish these builds and add the suffix 'Demo' to the name of the product:

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

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

How can I make work this?

Upvotes: 0

Views: 471

Answers (2)

Simon
Simon

Reputation: 4794

I got a solution by my self. I can distinguish between the demo and the release using var.ProjectName.Configuration and Wix´s preprocessor.

This is my switch:

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

Adding the suffix (Demo) to my Product:

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

Upvotes: 1

OpenMinded
OpenMinded

Reputation: 486

With the following code you can define producttarget WiX variable based on Configuration MSBuild property:

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

And then use producttarget in your Product declaration:

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

Upvotes: 3

Related Questions