In wix 3 you could specify a condition inside the custom element.
In wix 4 the same element does not seem to accept inner text anymore. If you try to set a condition the compiler throws a The Custom element contains illegal inner text: 'NOT Installed AND NOT UPGRADINGPRODUCTCODE' error. How would one go ahead and only run the custom action during the installation now?
Condition is an attribute on the Custom element: https://wixtoolset.org/docs/reference/schema/wxs/custom/
I ended up checking the REMOVE parameter inside the custom action itself to check whether it got called during a uninstall and then run the logic accordingly.
var isUninstall = session["REMOVE"] == "ALL";
The only problem with that solution is that this way I cant make sure that the custom action logic does not run on patches as well.
Pro Tip: WiX's v3 to v4 code converter is really good. Author what you know in v3 and then convert it v4 and diff the before and after to quickly learn new changes in v4.
Related
I am using a WiX bundle with Xeam Visual Installer as a bootstrapper UI application.
What I would like to do is set some variables inside the Custom Actions that my MSI is running, and I have figured out how to do that. I can see in my logs that the variables are being set.
My problem is I hoped that I would be able to read these variable and display them on the last page of my bootstrapper UI. Out here the variables still show as empty strings.
If you are familiar with Xeam, I am trying to access them like this:
MyProp = Bootstrapper.Engine.StringVariables["MY_PROP"];
Similar to the way you read and set properties during the initial bootstrapper workflow, before everything is sent to the MSI.
Has anyone else tried to do this. Should it be possible or are there any other solutions you can suggest?
This is apparently not possible. The solution is to use the registry instead.
I'm trying to add hyperlink inside of DisallowUpgradeErrorMessage (from here http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html):
<MajorUpgrade AllowDowngrades="no"
DisallowUpgradeErrorMessage='Older version of MWL installed. Please follow https://example.com/uninstall.html'
/>
I already try to create HTML hyperlink inside message, but got error, something like
"invalid character inside of attribute"
I replace <> characters with < and >, but it not work (shown as plain text). Is there any other ways to do this?
The default WiX dialogs do not support hyperlinks in their text so you will have to create your own custom UI rather than relying on the condition elements. You can find an example of how to do this here.
However, for the case you have mentioned you can have WiX automatically uninstall the previous version of your software. In cases such as this I have found the Upgrade element to be more useful than MajorUpgrade, it allows for granular control of conditions and actions. You can view an example of using the Upgrade element as well as forcibly removing existing products here.
Can I set the TRANSFORMS argument value in the custom action within the MSI ? If Yes, need to set the custom action being called at which stage ? Thanks.
Transforms can't be applied dynamically during an installation. They have to be applied at the time the installation is started. A custom bootstrapper (EXE) could use business logic to select a transform and apply it when starting the installation.
You can also embed the mst files into the _Storages table inside the MSI, and windows will auto-detect the supported transforms for you.
https://msdn.microsoft.com/en-us/library/aa368351(v=vs.85).aspx
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 an MSI packages that executes a number of deferred custom actions during product install. If one of custom actions fails, installation ends with standard "Installation was cancelled..." window. This "cancelled" text is very confusing to end user, and i want to modify it in case my custom action fails an i know what is a problem.
I have tried to queue custom action after ExecuteAction but was faced with a problem: this action is executed only on installation success, but not on instllation failure! After that i have tried to queue my custom action to be executed at installation failure by assigning it a sequence number of -3. It is executed - but in server context, so it can't change text that is displayed in client context!
Is it any way to change this text? I need a custom action that is executed in client context (immediate mode) after installation fails.
Did you try to use Error Table?
(add your own error description into this table and return its code)
Take a look at src\ext\UIExtension\wixlib\WixUI_en-us.wxl in WIX source.
Find String ID of your text and add (for example into Product.wxs):
<String Id="STRING_ID_HERE">New text</String>