Automatically update version info in wix installer - wix

Hi I have a C/C++ Header file with my products version info init as follows:
#define nMajorVersion 4
#define nMinorVersion 4
#define nPointVersion 8
#define nBuildVersion 33
#define s_szFileVersion "4.4.8.33"
#define s_szProductVersion "4.4.8.33"
Is there any way I can automatically read from this file to update my version number in my wix 3.6 installer? At the moment I have it hard coded and this is not ideal for when it is released. Thanks

What you can do is create a c/c++ program which generates a file Version.wxi which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define ProductVersion.Major="4"?>
<?define ProductVersion.Minor="4"?>
<?define ProductVersion.Revision="8"?>
<?define ProductVersion.Build="33"?>
<?define ProductVersion="4.4.8.33"?>
....
</Include>
Then you can include and use those version numbers in the main wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include Version.wxi ?>
<?define UpgradeCode="GUID"?>
<Product Id="*"
Name="$(var.ProductName) $(var.ProductVersion.Major).$(var.ProductVersion.Minor)"
Version="$(var.ProductVersion)" Language="1033"
Manufacturer="$(var.Company)" UpgradeCode="$(var.UpgradeCode)">
Generate the Version.wxi just before you compile your wix project. For example modify the .wixproj file to add a target which does that.

Related

Wix Installer with Major Version Subfolder

I have the following code in my Product.wxs file
<Wix>
<?define ProductVersion="!(bind.fileVersion._957E198E_2074_A3FA_A554_6FE5D8E9F4FD)" ?>
<?define MajorVersion="!(bind.property.ProductVersion.Major)" ?>
<Product Id='*' Name='Software v$(var.MajorVersion)' Version='$(var.ProductVersion)' Manufacturer='...' UpgradeCode='...' Codepage='...'>
[...]
</Product>
</Wix>
The above is based on this Binding WIX FileVersion sub values? question's answer.
It gives me the following error though
My Plan B was smth like
<?define MajorVersion="!(bind.fileVersion._957E198E_2074_A3FA_A554_6FE5D8E9F4FD.Major)" ?>
or
<?define MajorVersion="!(bind.fileVersion.major._957E198E_2074_A3FA_A554_6FE5D8E9F4FD)" ?>
but those don't work either.
Ultimately I want to use the MajorVersion property/variable to be part of the install directory.
<CustomAction Id='DIRCA_TARGETDIR' Property='TARGETDIR' Value='[ProgramFilesFolder][Manufacturer]\[MajorVersion]\[ProductName]' Execute='firstSequence' />
Any help is greatly appreciated.
After some more digging I eventually found an answer myself.
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<?define MainAssemblyVersion="!(bind.fileVersion._957E198E_2074_A3FA_A554_6FE5D8E9F4FD)" ?>
<?define MajorVersion="!(bind.property.ProductVersion.Major)" ?>
<Product Id='*' Name='Software v$(var.MajorVersion' Language='1033' Version='$(var.MainAssemblyVersion)' Manufacturer='...' UpgradeCode='...' Codepage='...'>
[...]
<!-- Initialize the 'TARGETDIR' directory property. -->
<CustomAction Id='DIRCA_TARGETDIR' Property='TARGETDIR' Value='[ProgramFilesFolder][Manufacturer]\[ProductName] v$(var.MajorVersion)' Execute='firstSequence' />
[...]
</Product>
</Wix>
I believe I was partly confused by the fact that bind.property.ProductVersion already exists and doesn't have to be declared (which I did in my first example)
Once you have the major version part in a variable, using it $(var.MainAssemblyVersion) is really all it needs.

Unresolved reference to symbol 'Property:VS2019DEVENV' in section 'Product:*'

I am getting this error "Unresolved reference to symbol 'Property:VS2019DEVENV' in section 'Product:*'" In my Wix setup project I tried the following solutions
Updated Wix toolset version into the latest 3.14
Added reference of WixVSExtension.dll into the setup project
I changed VS2019DEVENV to VS2017DEVENV and build is succeeded for vs2017. Please find the code below
<?xml version="1.0" encoding="utf-8"?>
<!--
# This comment is generated by WixEdit, the specific commandline
# arguments for the WiX Toolset are stored here.
candleArgs:
lightArgs: "<projectname>.wixobj" -out "<projectname>.msi" -ext "C:\Program Files (x86)\WiX Toolset v3.14\bin\WixVSExtension.dll"
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define PRODUCT_VERSION="14.0.0.1" ?>
<?define MANUFACTURER="sample"?>
<?define PRODUCT_NAME="test"?>
<?define UPGRADE_CODE="{8F258A2B-2203-43C2-A63C-B829E552F327}"?>
<Product Id="*" Name="$(var.PRODUCT_NAME) v$(var.PRODUCT_VERSION)" Language="1033" Version="$(var.PRODUCT_VERSION)" Manufacturer="$(var.MANUFACTURER)" UpgradeCode="$(var.UPGRADE_CODE)">
<Package Compressed="yes" />
<PropertyRef Id="VS2019DEVENV" />
The version of wix binaries is my problem and I updated those with v3.14
and updated the path in build settings also
".wixobj" -out ".msi" -ext "C:\Program Files (x86)\WiX Toolset v3.14\bin\WixVSExtension.dll"

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"

single msi for 32-bit and 64-bit depend on target machine

Using WIX, I need to create an msi or exe that should work in both 32-bit and
64-bit machines depend on system.
You can't, because the MSI format requires you to specify the processor architecture. So you must create two separate .msi files, but you can at least generate them from the same project file in Wix, which avoids some duplicate work.
I use this:
<?if $(var.Platform) = x64 ?>
<?define ProductName = "InsomniacGeek: Windows Setup Test (64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define ProductName = "InsomniacGeek: Windows Setup Test" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="$(var.Platform)"/>
Then you would have to build the project and create a 32-bit Msi and 64-bit Msi.

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>