<?foreach...?> statements provide for the creation of multiple sets of
elements within the wix file itself. It is <?if...?> constructs that suggest
(but don't necessarily require) multiple MSIs.

What I suggested is a way to manage the creation of sets of multiple
components and properties that differ in a consistent fashion to minimize
the code duplication of what are needed to be component sets that differ
only in a single set of values. It prevents the copy-paste-tweak cycle of
development by making the tweak apply in an obvious fashion to only one copy
of the source so that it is maintainable, which is exactly what you asked
how to do.

The effect is to generate both a SetProperty action and a series of
conditional components that install based on an "environment" setting
supplied at install time in a single MSI. I gave a template based on the two
environments you supplied in your sample code that should be expanded based
on the pattern given.

-----Original Message-----
From: Maillet, Ed [mailto:email...@unum.com] 
Sent: Wednesday, August 26, 2009 6:16 AM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Dynamic Property Values vs. Multiple Components


Doesn't the using the preprocessor statements essential force the
creation of multiple MSIs? One per environment?
For what I need, I must have a single MSI that works in all
environments.

I did get the Multiple Component approach to work but it seems like a
weird way to do it.

----- Ed

------------------------------------------------------------------
Date: Tue, 25 Aug 2009 16:56:38 -0700
From: "Blair" <os...@live.com>
Subject: Re: [WiX-users] Dynamic Property Values vs. Multiple
        Components


Wrap the <SetProperty>s with <?foreach...?> for the "common" ones AND
the ones that vary based solely on the name of the environment?

<?foreach env in DEVELOPMENT;PRODUCTION?> <?if $(var.env) =
"DEVELOPMENT"?> <?define shortEnv = "DEV"> <?elseif $(var.env) =
"PRODUCTION"?> <?define shortEnv = "PROD"> <?endif?>

<SetProperty Id="USER_DOMAIN_PROP" Value="DOMAIN$(var.shortEnv)" ...>
      <![CDATA[%ENVIRONMENT = "$(var.env)"]]> </SetProperty>

<?undef shortEnv?>
<?endforeach?>

Note: this is a quick-and-dirty example. I haven't compiled it, but is
should basically be what you are looking for.

-----Original Message-----
From: Maillet, Ed 
Sent: Tuesday, August 25, 2009 10:01 AM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] Dynamic Property Values vs. Multiple Components

Hey all,
   Looking for some direction and opinions. I need to create an hands
free (no UI/prompting etc) MSI that installs Web Site and app pool on
IIS 6.0. The catch is that the user info and host header info need to be
derived based on an environment variable on the target machine. I have
10 different environments (DEV, PROD, STRESS, etc). The mapping between
environment variable and the other info is static (e.g. env = A always
yields Header = X, etc)

It seems more natural to me to have properties who's values get set at
runtime rather than multiple components with conditions (or Features
with conditions)

Unless I'm missing something, there seems to be no easy way in Wix 3 to
dynamically set the value of a property without making a CustomAction.
The SetProperty doesn't seem to help since you can't do:
 <SetProperty Id="USER_DOMAIN_PROP" Value="DOMAINDEV" ...>
      <![CDATA[%ENVIRONMENT = "DEVELOPMENT"]]>  </SetProperty>
<SetProperty Id="USER_DOMAIN_PROP" Value="DOMAINPROD" ...>
      <![CDATA[%ENVIRONMENT = "PRODUCTION"]]>  </SetProperty>


But replicating the Component XML containing the iss:Web* elements and
tweaking 10 times seems like a bad idea. 95% of the contents are the
same and some day someone will forget to update them all correctly.

Thoughts?

----- Ed



----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus
on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to