WIX: How to display variable in custom dialog box? - wix

I would like to display some variables in custom dialog box. For example I would like to inform users about a version number of a product beeing installed.
Header of the main .wxs file is:
<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion = 1.0.20.15?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="BNS"
Language="1029"
Version="$(var.ProductVersion)"
...
If I try to add this Control tag to dialog box:
<Control Id="VersionNumber" Type="Text" X="20" Y="175" Width="290" Height="30" Transparent="yes" Text="$(var.ProductVersion)" NoPrefix="yes"/>
"Undefined preprocessor variable '$(var.ProductVersion)'." error occurs when I try it to build.

You should make candle aware of this preprocessor variable. Use '-d' switch for this. For more information, type "candle" in console.

Related

Overriding text color in Wix

I am struggling to learn the wix toolset, and currently want to do something I should think would be very simple: change the color of the text displayed in the dialog boxes defined in the toolset.
I found a stackoverflow answer which said I could do this by customizing WixUI_Minimal (which is the dialog set I'm using), giving it a different ID, and referencing that ID in my main wix file. The customization would simply be to do this:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI Id="WixUI_Custom">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" Red="255" />
And the reference in my main wxs file would be changed to:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="Lan History Manager"
Language="1033"
Version="0.5.0.0"
Manufacturer="Jump for Joy Software"
UpgradeCode="EB2D1FB0-A72E-466C-B12D-BCF84277E2DA">
<Package InstallerVersion="500"
Compressed="yes"
InstallScope="perMachine"
Manufacturer="Jump for Joy Software"
Description="Installs a tool for managing Windows File History backups to network shares"
Comments="(C) 2017 Mark A. Olbert all rights reserved"/>
<UIRef Id="WixUI_Custom"/>
Unfortunately, this does not work. When I compile the project, it generates dozens of errors, complaining about duplicate symbols, all of which appear to relate to other parts of the WixUI_Minimal "template" which I did not change.
I do not have any definition for WixUI_Minimal present in my project, and no references are made to WixUI_Minimal, so it shouldn't be dragging in the duplicate symbols.
But something obviously is.
Is there some other way of just changing the text color in the dialogs?
The WiXUI_* can only be extended and overridden in limited ways. To go where you want to go you pretty much have to take a copy of it and own it. Go to the WiX sources and find the files that define all of this in the UI Extension. Clone them into your project and eliminate the UI extension. Now you can go and change anything you want about it.
Alternatively you could also decide to go full silent in the MSI and do all your UI work in a burn bootstrapper theme and/or customer bootstrapper application.

How to replace autogenerated product name in install dialog?

I'm using WiX 3.9.1208.0 to generate installer and bootstrapper for my application. I've just added digital signature to avoid a yellow warning when the installer is executed. I now get a friendly dialog prompting for elevated privileges where a program name and verified publisher is displayed, but the program name is a random auto-generated value instead of the real product name used in the <Product> element in the .wxs file.
<?xml version="1.0" encoding="utf-8"?>
<?include $(sys.CURRENTDIR)\Variables.wxi?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="My Product" Language="1033" Version="!(bind.FileVersion.MyProductExe)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
Why isn't "My Product" displayed as Program name, and what can I do to fix this?
Use the /d argument to the SignTool to give a friendly name. I.e.: /d "My Installer"

Wix creating multilanguage msi

recently I'm working on creating a multilanguage wix msi package for my team. I searched the localization on Google and also on stackoverflow for quite some time and finally found something to follow:http://www.geektieguy.com/2010/03/13/create-a-multi-lingual-multi-language-msi-using-wix-and-custom-build-scripts/. Currently I just added 2 language support: english and simplified Chinese to check if this approach works for me. The main wxs front part is something like this:
<Product Id="B5CB3C6A-A8ED-4308-8ADE-17729FE1FB23" Name="MyProduct" Language="!(loc.LANG)" Codepage="UTF-8" Version="11.51.0027" Manufacturer="My Company" UpgradeCode="D42070C3-43CB-4E2B-9B96-2F8D84A6C8A8">
<Package InstallerVersion="200" Compressed="yes" Languages="1033,2052" InstallPrivileges="elevated" InstallScope="perMachine" />
And for the Language attribute of the Product I'm getting value from the localization wxl file, I've 2 files now, one is en-US.wxl, another is zh-CN.wxl,
in en-US.wxl: 1033
in zh-CN.wxl 2052
I also set the corresponding codepage in 2 wxl files, setting en-US codepage to 1252 and zh-CN to 936.
After building the project in VS, I got 2 msi, one in en-US folder and another in zh-CN folder, and I use the following commands to create the multilanguage msi:
cscript WiLangId.vbs zh-CN\MyProduct.msi Product 2052
Msitrans.exe -g en-US\MyProduct.msi zh-CN\MyProduct.msi zh-CN.mst
cscript WiSubStg.vbs en-US\MyProduct.msi zh-CN.mst 2052
cscript WiSubStg.vbs en-US\MyProduct.msi
And performing the commands above in cmd, I copied the final msi onto a Chinese win7 system to try, the problem is after I double clicking the msi to install, the first UI dialog is still in English but shortly it became Chinese, I'm sorry that I couldn't post the screenshot here because stackoverflow requires 10 reputations to be able to post images, but the words on the first Dialog I saw is "Preparing to install...." and a button on the bottom right "Cancel" and then after 2-3 seconds the UI became Chinese. Did anyone come up with this problem before?
Windows System restore point is created by default (if enabled system-wide) at the start of a MSI install. This system restore point seems to occur before locale transform and cause the behavior you observed.
You can disable it by setting MSIFASTINSTALL property to 1 or any value that includes it (e.g. 5 if you also want to reduce the amount of progress messages)
<Property Hidden="yes" Id="MSIFASTINSTALL" Value="1" />
For example in your .wxs file:
<?xml version="1.0" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
<Product Id="XXX" Name="XXX" Language='!(loc.LANG)' Codepage='0'
Version="XXX" Manufacturer="XXX"
UpgradeCode="XXX">
<Product Id="B5CB3C6A-A8ED-4308-8ADE-17729FE1FB23" Name="MyProduct" Language="!(loc.LANG)" Codepage="UTF-8" Version="11.51.0027" Manufacturer="My Company" UpgradeCode="D42070C3-43CB-4E2B-9B96-2F8D84A6C8A8">
<Package InstallerVersion="200" Compressed="yes" Languages="1033,2052" InstallPrivileges="elevated" InstallScope="perMachine" />
<!-- Disable System Restore point creation for this MSI (faster installation) -->
<Property Hidden="yes" Id="MSIFASTINSTALL" Value="1" />
<!-- Rest of your setup ... -->
</Product>
</Wix>
You can read about MSIFASTINSTALL on Microsoft Windows docs

How to decouple things in Wix?

I want to install a product with some dll with Wix 3.5.
These dll are determined during the msi installation through a radio buttons group.
I have :
a (fragment) wxs for myDllv1
a (fragment) wxs for myDllv2
a (UI fragment) wxs with the RadioButtonGroup to choose between myDll v1 and myDll v2 with a property INSTALLTYPE
a main wxs file which installs the correct version of myDll.
Problem : I have another set of dll to add and I want to modify as less files as possible.
I don't want to introduce bugs and I want to keep things decoupled.
I would like to modify only the UI fragment with the radio buttons and add a myDllv3 fragment (without doing any changes to my main wxs file, so no condition in that file..).
Is it possible?
Why don't you use pre-processors to select the correct fragments when building the msi?
<?if $(env.SomeBuildParameter) = SetA ?>
<?include myDllSetAv1.wxs ?>
<?include myDllSetAv2.wxs ?>
<?else ?>
<?include myDllSetBv1.wxs ?>
<?include myDllSetBv2.wxs ?>
<?endif ?>
I may be misunderstanding the question, but it sounds like your different set of Dlls should be grouped by features within WIX. I'd suggest creating independent WIX fragments that represents a feature for each of your set of Dlls and then you can tie your UI to install a specific feature as appropriate.
You represent a feature at the product level like so:
<Feature Id="Feature.One" Title="Feature One">
<ComponentGroupRef Id="FeatureOneDlls.Group" />
</Feature>
<Feature Id="Feature.Two" Title="Feature Two">
<ComponentGroupRef Id="FeatureTwoDlls.Group" />
</Feature>
And within each of the features I'd recommend using a separate wxs file to supply the fragment information that contains the files for that feature.

Is it possible to change the language code of WiX depending on what language the OS is in?

I already know about the UserLanguageID and SystemLanguageID properties, but is there any way I could put this number into the language attribute of the Product tag?
I'm probably either doing something very wrong, or it can't be done.
Thanks
UserLanguageID and SystemLanguageID are runtime properties, ie they don't exist until the MSI actually runs. The product's language code, on the other hand, is determined when the MSI is generated by the Wix toolset. AFAIK there's no way to change it dynamically.
Short answer: it can't be done.
You're not very clear about what it is you're trying to do... however I use something like the following. Don't know if this will help?
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" Codepage="1252" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Language">en-US</String>
<!-- .... -->
</WixLocalization>
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
UpgradeCode="$(var.Property_UpgradeCode)"
Name="!(loc.ApplicationName)"
Language="!(loc.Property_ProductLanguage)"
Version="$(var.version)"
Manufacturer="!(loc.ManufacturerName)" >
<!-- .... -->
</Product>
</Wix>