CustomActionData Property

Switch View :
ScriptFree
Deployment in Visual Studio
CustomActionData Property

Specifies additional data that can be evaluated by a custom action during installation. Custom actions are run at the end of an installation and cannot access information about the installation; the CustomActionData property allows you to store information about the installation that can be read by the custom action.

For example, if your deployment project included a file search with a Property property of FILESEARCH1, you could pass the value returned by the file search by setting the CustomActionData property to /MyFile=[FILESEARCH1]. In your custom action, you could query the MyFile property to retrieve the value.

Remarks

The format for the CustomActionData property depends on the type of the custom action.

  • For custom actions that are installation components (ProjectInstaller classes), the CustomActionData property takes a format of /name=value. Each name must be unique and have only one value. Multiple values must be separated by a single space: /name1=value1 /name2=value2. If the value has a space in it, it must be surrounded by quotation marks: /name="a value".

    Windows Installer properties can be passed using the bracketed syntax: /name=[PROPERTYNAME]. For Windows Installer properties such as [TARGETDIR] that return a directory, in addition to the brackets you must include quotation marks and a trailing backslash: /name="[TARGETDIR]\".

    Note Note:

    In order for a custom action to be treated as an installation component, the InstallerClass property must be set to true. For more information, see RunInstallerAttribute.

  • For all other custom actions (.exe, .dll, or script), there are no format requirements. You can pass any string in the CustomActionData property, since you must parse it yourself in your custom action.

Troubleshooting

If your custom action relies on customers typing a path to an installation folder, you may see a ArgumentException error message. This may be related to an invalid directory or URL.

To prevent this error message, replace the backslash with a space: /name="TARGETDIR] ". Then, parse the value and create a fully qualified path using the Combine method.

See Also

Tasks

Reference

Community Content

Stefan 000000
You do not need /name="[TARGETDIR]\" take this one: /name="[TARGETDIR] "
It took me hours to find the right hint in this document. It is not only needed if you use cutom input; it's also needed for some parameters.

BTW: It should be /name="[TARGETDIR] " instead of /name="TARGETDIR] "

Stefan