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.