How can I get WiX to call a method in a .NET assembly as part of the installation process?

左心房为你撑大大i 提交于 2020-01-01 15:41:17

问题


I'm migrating some existing products to use WiX 3.5 (I'm using the Votive VS integration). Some of the items I'm installing need to be registered with a third-party framework. The requirement is that I must call a Register() method in a third party .NET assembly to inform it of the presence of the items I'm installing. It expects a COM ProgID.

I can't figure out how to get WiX to do this. I thought about creating a binary Custom Action, but I can't find a way of passing a parameter (a string containing the ProgID) into that custom action. I don't want to hard-code it because I need this to be re-usable code. I can't see a way to do this declaratively because the Register() function is a 'black box'.

Man this is a steep learning curve. What's my best approach here?


回答1:


Look at the Deployment Tools Foundation (DTF) for WIX. There is a DTF.chm file with the WIX installation with lots of information.

Assuming you installation process is something like

  1. Setup installation, input parameters/ProgID, do validation, etc.
  2. Begin actual installation of files
  3. Call registration methods

You'll need two Custom actions (ignoring rollback and uninstallation)

  • SetupRegistration
  • DoRegistration

SetupRegistration should be an immediate custom action fired either from the UI or late in the setup phase. It grabs the ProgID and any other data needed, uses a CustomActionData object and assigns that to a property named "DoRegistration" (Important, the property name must be the same as the second custom action)

The DoRegistration is a deferred custom action and needs to be scheduled in the InstallExecuteSequence probably after InstallFiles, but that depends. It pulls the Session.CustomActionData property and gets the ProgID out, then calls whatever registration method you need.




回答2:


Am using a sort of what you have described.

I use to call CustomAction(events) when required. Like on clicking button you can call a method which will do work for you.

Calling custom action like:

<Custom Action="ActionName" After="InstallFinalize">CONDITION = "1"</Custom>

Or calling custom action based on specific button click:

<CustomAction Id="TestConnection" BinaryKey="SetupCustomActions" DllEntry="TestConnection" Execute="immediate" Return="check" />


来源:https://stackoverflow.com/questions/3902677/how-can-i-get-wix-to-call-a-method-in-a-net-assembly-as-part-of-the-installatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!