4

I'm creating a program which is being installed by Wix, using VS 2010 and I've already got the product.wxs ready.

Now I want to add a custom C# action to the installation. I've searched how to do it and found this guide: How do I create fully fledged C# custom actions?

The problem is that I don't understand all the instructions, specifically in this section of the guide: Integrate the C# custom action in Advanced Installer

I've created the Custom Action project but I don't understand how do I tell the setup project to run that custom action and how do I set the action to run at install in the commit phase.

Another related thing. How in the C# code can I get the installation path that the user chose to install to?

slugster
  • 49,403
  • 14
  • 95
  • 145
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203

1 Answers1

8

That tutorial is for how to use WiX managed custom actions with "Advance Installer", a commercial tool for creating installers.

Here is a good explanation on how to create WiX Custom Actions in C#, to use with the WiX toolset.

Andres Denkberg
  • 361
  • 2
  • 9
  • Do you know how can I get the installation path in the code? Probably from the Session parameter? – CodeMonkey Oct 13 '13 at 12:41
  • You can use the session parameter to get the value of any property, (for example: string propValue = session["MYPROPERTY"];). The property that contains the installation folder may depend on your code. – Andres Denkberg Oct 13 '13 at 12:59
  • How can it depend on my code? There's supposed to be only a single property with the installation path – CodeMonkey Oct 13 '13 at 13:35
  • It is defined by you setup Directory structure, or in case you are using the WixUI_InstallDir dialog set then a look at the sample [in this link](http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html) – Andres Denkberg Oct 13 '13 at 13:42
  • But I'm talking about the custom action C# code. Not the wxs file code – CodeMonkey Oct 13 '13 at 13:48
  • Yes, but the property that contains the installation path is defined by you in the wxs file. the Id attribute (is the property name) of the Directory element contains the path. and you can access that Id (property ) to get its value from the Custom Action. Have a look in this [tutorial](http://wix.tramontana.co.hu/tutorial/getting-started/the-files-inside) and in the [wix documentation](http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/add_a_file.html), for a an explanation on the Directory structure. – Andres Denkberg Oct 13 '13 at 14:04