13

I am using Wix3 to install WCF service to IIS.

How can I use my custom action (c#) function after installation completed? i.e. I need to open installed web.config file and replace hostname with real one.

Any ideas?

radbyx
  • 9,352
  • 21
  • 84
  • 127
ZedZip
  • 5,794
  • 15
  • 66
  • 119

3 Answers3

11

You can schedule it after InstallFinalize action in InstallExecuteSequence.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • Accurate for sequencing it when he wants, but Christoper's answer is a better solution for what he actually wants to accomplish. – Rob McCready May 19 '11 at 00:51
9

There is a sequence of Actions in Windows Installer. The WiX tutorial has a good section on events (and is a great resource anyway).

A typical example of getting something to run after InstallFinalize is to get the installed app to start.

<InstallExecuteSequence>
   <Custom Action='LaunchFile' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
Peter Kelly
  • 14,253
  • 6
  • 54
  • 63
  • 1
    If your `CustomAction` is using the `ExeCommand` property of the `CustomAction` to execute a script command, this won't work and reports a compile time error of: "*[Insert Action ID Name] is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table*" – Code Doggo May 28 '20 at 00:04
6

Why would you:

1) Need a custom action? 2) Do it after the install instead of during the install?

WiX has a built-in extension for handling what you are trying to do:

XmlFile Element (Util Extension)

It will update your XML after the file has been installed and handle rollback scenarios as well.

What you will have to write a CA for though is reading the XML value back into a property ti handle repair and upgrade situations. Read:

The WiX toolset's "Remember Property" pattern.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • help here: https://stackoverflow.com/questions/57264361/failed-to-open-xml-file-wix-unable-to-update-appsettings-json – kudlatiger Jul 30 '19 at 10:15