views:

87

answers:

2

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?

+2  A: 

Use the preprocessor, e.g.: to conditionally include/exclude components based on configuration.

Bob Arnson
I haven't thought that Wix could have preprocessing! I've found the man http://wix.sourceforge.net/manual-wix2/preprocessor.htm
Luca
+1  A: 

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.

Stuart Lange