Is there a way to execute a command (in PoSh, ideally) and assign the output to the value of a property in WiX? So far, all I have seen is custom actions that will run a command, but not capture output or set a property's value.
Custom actions can access the Wix Session and set a property on the session that can be read out later.
This is C# code but it would be similar in PS
[CustomAction]
public static ActionResult myaction(Session session)
{
session["myvariable"] = "myvalue";
}
After the action has been executed you can access it in the UI as if it where a normal property. Be aware though that if you are planning on changing the UI to respond to this you will need to use a hack to make the wix UI realise that the value has changed...see my answer in this SO question Wix Interactions with Conditions, Properties & Custom Actions
Related
I've noticed that when a control such as an AutoSuggestBox has a callback, the callback is executed both when a user interacts with the control and when my code changes the associated value.
For example, if I set the TextChanged property on an AutoSuggestBox, the function is called even when my code sets the Text property to an initial value.
This is causing problems in my application in the form of both bugs and unnecessary function calls. You may be wondering how the code came to be in this state -- the answer is, I don't know. The project was handed off to me from another developer and I've been tasked to fix a number of bugs.
Although I can individually hunt down all the places in the code where this happens and temporarily remove the callback, I'm wondering if there is an easier way, for example a property I can set on the control that says, "don't call the callbacks when it is the code making a change rather than the UI".
For the AutoSuggestBox.TextChanged event, the attribute of the trigger reason is provided in AutoSuggestBoxTextChangedEventArgs, and you can judge based on this
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if (args.Reason == AutoSuggestionBoxTextChangeReason.ProgrammaticChange)
{
return;
}
//other code
}
For other controls, you need to deal with them according to your situation.
Best regards.
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 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.
Can a CommandParameter be passed to a Command in WinRT? How?
Actually, I may have misunderstood your question entirely. If you are talking about UI commands (commands that implement the ICommand interface) you can pass parameters when you call Execute. You can also test if the command and parameters are valid before executing the command by calling CanExecute.
As for passing a parameter as part of a Button binding, set the Command property equal to the command you want the button to execute and set the CommandParameter property equal to the parameter you want to pass.
Yes and no. WinRT applications can receive parameters through the Application.OnLaunched override.
The override receives an instance of type LaunchActivatedEventArgs which includes the arguments.
So it is possible to receive arguments, the question is more about how they can be passed.
Windows Store (WinRT) applications cannot be started from the command line. If a WinRT application is associated with a file type, it can be launched by calling ShellExecute on a file. Other than that, the application cannot be started directly.
It is possible to write C++ that launches a WinRT application using the IAplicationActivationManager interface and this interface can pass parameters to the launched application. So you could create a C++ launcher executable that could be called from the command line.
For more information on how to launch an application using this interface, see the following forum post:
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/a4d2fca1-4034-4cc7-a86a-6242ce1a8b16
I want to pass a file name in the argument of Custom Action. These files are getting installed into the system. Can I pass the component id of these files rather than passing hard coded name?
Since Wix has provided Session variables to communicate with C# custom actions ....assign your files path in some Session variable and use it in custom action...
Make sure that the variable name should be in CAPS