I am trying to diplay label "Install" or "Uninstall" based on the action being performed by the wix burn installer. So far I have tried this:
<?define InstallStatus=[WixBundleAction]?>
<?if $(var.InstallStatus) = 5?>
<Variable Name="StatusLabel" Value="Install"/>
<?else ?>
<Variable Name="StatusLabel" Value="Uninstall"/>
<?endif ?>
But it always returns Uninstall. When I checked the log file, I got Initializing string variable 'StatusLabel' to value 'Uninstall'.
When I tried to print InstallStatus, it had no value (""). Seems like it is not set till then.
Is there any other way to achieve it?
<?define InstallStatus=[WixBundleAction]?> is preprocessor code that is evaluated at compile time but WixBundleAction is a Burn variable that isn't available until runtime. In v3.x you have to write code to set a Variable at runtime. In v4, there's a new SetVariable element implemented in #4948 that allows declaratively setting the variable like you're trying to do.
If you're using wixstdba, then you probably want to know about #4149 which added support for showing a different message for install vs uninstall.
Related
I've discovered how to access the parts within the MSI/Product tag. But my goal was to set the caption of the burn installer based on the Major/Minor version number.
This code below is the summary of what I tried to do, but this doesn't work (I think because I'm not within the Product tag).
Burn wxs:
<Wix>
<Bundle Version="!(bind.packageVersion.<packageName>)" >
<Variable Name="ProductVersionMajor" Value="!(bind.property.ProductVersion.Major)"/>
<Variable Name="ProductVersionMinor" Value="!(bind.property.ProductVersion.Minor)"/>
....
Theme.wxl:
<WixLocalization ...>
<String Id="Caption">[WixBundleName] [ProductVersionMajor].[ProductVersionMinor] Setup</String>
....
Is there some kind of work around where I can get this information at the bundle level without writing custom code?
This answer here was useful, but not quite what it appears I need; since I'm not within the WIX product tag for the inner MSI.
!(bind.property.ProductVersion.Major) is a bind variable when building an MSI, not a bundle. The available bind variables are documented at https://wixtoolset.org/documentation/manual/v3/overview/light.html. There is an open feature request for MsiPackage property bind variables at https://github.com/wixtoolset/issues/issues/4298. It would likely be additional work to get the ProductVersion.Whatever part working, so if you want that then you should add a comment to that issue.
In addition to #Sean's answer, if you are only interested in the full version and not in any breakdown of major/minor/build then the below example I have the caption in the localization WXL file can be defined as simple as:
<WixLocalization Culture="en-us" Language="1033" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Caption">[WixBundleName] Setup (v. [WixBundleVersion])</String>
...
and in my bundle.wxs file I have the following definition:
<Bundle Name="$(var.MyProductFullName)"
Version="!(bind.packageVersion.MyPackageId)"
Manufacturer="!(bind.packageManufacturer.MyPackageId)">
...
where the variable MyProductFullName is defined in my variables file under my package's installer project. So basically the [WixBundleName]
and [WixBundleVersion] are bound to the Bundle element's Name and Version attribute values, respectively.
I have been asked to add a function to an existing WiX package.
Specifically, I need to run a small c# application and return a single int back to WiX to conditionally control further actions.
I can see from ExePackage help that there is an ExitCode, but this is an enumeration of success, error, scheduleReboot or forceReboot.
I have googled quite a bit and I am wondering if I am missing the point. I can probably implement the C# process internally within WiX to get the user to provide the information I need, but the existing package already has custom ExePackages written in C# with a particular style, so I'd like to stay with that if I can. (The existing packages don't return any needed values)
Can I do this, or do I need to try and operate entirely within WiX?
For reference, one of the existing packages looks like this:
<ExePackage
SourceFile="..."
DisplayName="License Key"
InstallSize="0"
Permanent="yes"
InstallCommand="/ignoreIfLicensed"
RepairCommand="/ignore"
UninstallCommand="/ignore"
/>
The reference to <ExePackage ...> implies you want the condition to operate in a WIX bundle. In this scenario I think your options are limited and you can only map the return value of an ExePackage to global behaviour like forceReboot.
Do you have any <MsiPackage...> references? If you have, you could move the conditional behaviour inside each <MsiPackage...> using a Custom Action to call the exe and set a property. The property can then be used as a condition in each <component...> you want to conditionally install. See Using a WiX custom action to set a property's value for more information on custom actions setting properties.
I have a WiX bootstrapper theme xml file, and I want to permanently disable a control. I have tried to set HexStyle to the value of WS_DISABLED (link). However the control is still enabled. Anyone knows if I can use HexStyle or know of another way of having a control permanently disabled. I use the WixStandardBootstrapperApplication.RtfLicense BootstrapperApplication.
The possible solution is to find Id of this control and then create Variable with postfix "State". I hope it should work:
<Variable Name="EulaRicheditState" Type="string" Value="disable" />
How do I to pass in a WiX variable defined in another file (without redefining it again)?
It seems like the standard way of defining a variable is this:
<?define Var1= "****" ?>
That's right, you can define some variables in this syntax. Then include them in a separate WiX include file, with the extension .wxi. (like a .h include file), for example MyWixDefines.wxi. Then in your other WiX file Fragments, include this file, like this:
<?include MyWixDefines.wxi ?>
And finally, in the other fragments, you reference the variable like this:
<Icon Id="myIcon" SourceFile="$(var.Var1)\images\someicon.ico" />
A reminder: The variable is resolved at WiX compile time. It's not dynamically available at install time.
I am writing an installer using wix. For silent installation using msiexec, i would like to provide few parameters from the commandline which i want to set to wix properties.
These properties I am using to enable/disable few features.
Can anyone please tell me how to read those command line properties passed to msiexec.
Using C++ Custom Action we read using MsiGetProperty
Thanks a lot..
Best Regards,
Marc
To make the property available from the command line you should define it using an upper case name. I often use a launch condition to check the properties have been passed on the command line:
<Property Id="PROPNAME" Admin="yes" />
<Condition Message="Public Property PROPNAME not passed">Installed or PROPNAME</Condition>
The Installed variable only checks for the property value on install rather than uninstall.
The command line for msiexec looks like this:
msiexec -i <msiname.msi> PROPNAME="PROPVALUE"
You should also look into the ADDLOCAL property. You can probably simplify your problem with a command line like:
msiexec /i product.msi ADDLOCAL=FEATURE1,FEATURE2,FEATURE4,FEATURE5
A Feature element can use one or more Condition elements as children. A feature condition can use installer properties directly in their formatted form, for example:
[PROPERTY_NAME] = "value"
Each feature Condition element must use a Level attribute. In your case it can be 0 so the feature is not installed when the condition is met. Basically, you will set a condition for skipping the feature.