0

I have a large .wxs file and a requirement to change the Product Name from MyApp Workstation version to MyApp Server version when the installer is launched on a Windows Server operating system. I read a lot and I found out that I need to relate to the following MSI property MsiNTProductType which returns the value 1 for workstation and 2 or 3 for server operating systems.

<?xml version="1.0" encoding="UTF-8"?>
<?define ProductName = "MyApp Workstation version" ?>

<Wix>  
  <Product Name="$(var.ProductName)" ... >
     ...
  </Product>
</Wix>

If I use a condition like the following, it detects that I am on a workstation operating system (in my case Windows 10), but this is not what I want:

<Condition Message="This installer is for Windows Server only!">
      <![CDATA[(MsiNTProductType > 1)]]>
</Condition>

I tried the preprocessor variable approach, but evidently it does not work:

<?if MsiNTProductType = 1 ?>
<?define ProductName = "MyApp Workstation version" ?>
<?else ?>
<?define ProductName = "MyApp Server version" ?>
<?endif ?>

I also tried SetProperty and CustomAction without any luck. I am stuck at this.

Is it possible to do something like this? What changes do I have to make to accomplish this? I am very new to WIX and I do not understand how it is supposed to work. Thank you.

LATER EDIT AND SOLUTION

After many days of trying tens of combinations, I was able to do this with the following code which I put before any CustomActions that were already defined:

<Property Id="ConditionalProductName" Value="MyApp Workstation version" />    
<SetProperty Id="ConditionalProductName" Before="LaunchConditions" Value="MyApp Server version" >
   <![CDATA[(MsiNTProductType > 1)]]>
</SetProperty>
<SetProperty Id ="ProductName" Before ="LaunchConditions" Value ="[ConditionalProductName]"/>

I hope this may help others too. Good luck.

Alexandru Dicu
  • 1,151
  • 1
  • 16
  • 24
  • No time to answer properly tonight. However: preprocessor variables are compile-time construct that you can use to compile separate versions of your setup. This is how I would deliver a server and a workstation setup so they can be bug fixed independently for example - [more on that here](https://stackoverflow.com/a/1546916/129130). – Stein Åsmul Jan 16 '20 at 00:18
  • Setting the ProductName property at runtime via a custom action might work, but I wouldn't recommend it since the property is involved in product registration. The MSI file name must remain the same for both revisions to support patching (not sure of the product name). You can, however, change the ProductName in a transform - the concept used to customize MSI files for corporate deployment. A launcher setup.exe could apply a "server transform" for example at runtime to change the product name. – Stein Åsmul Jan 16 '20 at 00:19
  • [See my comments on patching here](https://stackoverflow.com/questions/59754016/wix-toolset-cannot-create-install-patch-with-fewer-files-components-than-the-o#comment105668009_59754016). There are other ways as well to show custom text based on target machine involving GUI changes. **What do you really need?** Should the setup change anything else or is it a "display issue"? Maybe you install different features? – Stein Åsmul Jan 16 '20 at 00:20
  • It is just a display issue. Nothing really changes, the features are the same. It is a PM thing which wants a different string displayed based on operating system. – Alexandru Dicu Jan 16 '20 at 09:39

1 Answers1

1

The ProductName property can only be changed prior to the installation starting. Once MSI is running it's immutable.

The preprocessor statements you are trying effect build time not installation time.

The only way to do what you want is create a transform with the different name and then use a bootstrapper to install the MSI without a transform on a non server OS and install the MSI with a transform on a server OS.

Personally this isn't typical practice so I would push back on the requirement from the PM. The only reason I would go through the effort would be the business really really differentiated the branding on the marketing side. Otherwise this just isn't normally done.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • With some GUI-hacking he could create a new label field to show a different display name? Hard work and error prone for very little gain? Maybe just inject a new welcome dialog? – Stein Åsmul Jan 16 '20 at 21:52