Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional installation with Wix

Is it possible to have a conditional installation configuration, slaved wth the Visual Studio configuration environment?

For example, selecting DEBUG or RELEASE configuration, Wix selects different executables in the built installation.

Basically I shall build different installations from the same projects, but they differs by the components. Some components are build from the same project, but built with different preprocessor options.

Of course it is possible to include every required component, and then define features in order to select a specific component for the installation, but I don't want really to redistribute some executables.

Build different Wix projects is the only solution?

like image 863
Luca Avatar asked Jun 10 '10 06:06

Luca


People also ask

How does WiX Installer work?

The WiX tools follow the traditional compile and link model used to create executables from source code. At build time, the WiX source files are validated against the core WiX schema, then processed by a preprocessor, compiler, and linker to create the final result.

What is WiX Cdata?

The term CDATA, meaning character data, is used for distinct, but related, purposes in the markup languages SGML and XML. The term indicates that a certain portion of the document is general character data, rather than non-character data or character data with a more specific, limited structure.


2 Answers

Putting the other two answers and Luca's research together I came up with this solution, which seems to work (note that the string comparison appears to be case sensitive, and the lack of quotes appears to be correct, I've tested this with WiX 3.7):

<?if $(var.Configuration) = Debug ?>
  <!-- DEBUG ONLY -->

  [ ... insert debug only XML here ... ]

  <!-- END DEBUG ONLY -->
<?else?>
  <!-- RELEASE ONLY -->

  [ ... insert release only XML here ... ]

  <!-- END RELEASE ONLY -->
<?endif?>
like image 82
BrainSlugs83 Avatar answered Nov 15 '22 23:11

BrainSlugs83


Your wix scripts have access to build parameters, like the Configuration ('debug' or 'release'). You can therefore conditionally include the correct binaries for the current configuration by referencing $(var.Configuartion) in your component declarations:

<Component Id="myProject.dll"
               DiskId="1"
               Guid="*">
  <File Id="myProject.dll"
            Name="myProject.dll"
            Source="..\myProject\bin\$(var.Configuration)\myProject.dll" />
</Component>

When you run the build in release mode, this script will pick up the release version of the binary. Likewise, in debug mode, the debug binary will be picked up. This approach does not require preprocessing - the script makes Configuration-related decisions at build time.

like image 39
Stuart Lange Avatar answered Nov 15 '22 23:11

Stuart Lange