Noah
Noah

Reputation: 1966

WIX Installer use user text to dictate the product name / command line params

I am struggling with WIX and value suggestions. I'm creating a skeleton windows service and have the code in the installer to correctly bundle the files and deploy a windows service, pass in command line arguments, etc.

However, the service has no operational logic deployed in the code - its all pulled at runtime from a WS that stores configuration information. I need to tell the windows service (at install time) which configuration name to use.

I also need to install the service so it is distinct from all others given that config name. A box can have n instances installed of this thing; each service pulling from a different config.

In short: I need to set a property (and product name) dynamically based on the user's input.

Here is what I'm trying with no idea how to proceed on getting the 'Config' value set by the user:

<!--    //todo: define this by user input??-->
<?define Config = "DefaultConfigName" ?>

<Product Id="*" Name="$(var.Config)" Language="1033" Version="1.0.0.0" UpgradeCode="{someGUID}">
  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

 <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />

 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."  />
 <MediaTemplate EmbedCab="yes" />

 <Feature Id="ProductFeature" Title="$(var.Config)" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
 </Feature>
</Product>

Thoughts?

Upvotes: 0

Views: 373

Answers (1)

tjleigh
tjleigh

Reputation: 1144

Firstly, remember that the <?define ... ?> thing creates a compile-time variable. i.e. the value will be compiled into your .msi, it will not be changeable at install time.

Secondly, I'm pretty sure the only way to change the product name of an already built .msi would be using a transform.

Both of the above points mean you would need to know every possible value of Config while creating your installer, and either create multiple .msis or create one .msi and multiple .mst transforms.

I suspect that this isn't what you want. Instead consider defining a public secure property. This property can be passed to the .msi on the command-line or set from a bootstrapper or MSI UI. You can then use that property in the ServiceInstall element attributes using the normal [CONFIG] syntax. The benefit of this approach is that you don't need to know every possible value of Config while building.

Upvotes: 1

Related Questions