c# - Trying to read a file and then write a file during a WiX install in a CustomAction -


update

this solved now, i've updated article future readers

i having tough time this. there lot of so articles these settings stuck.

my goal perform 2 steps:

1) read file physically shipped msi. in other words, there 3 files setup.exe, test.msi, specialfile.txt

2) during install, want create new file in install path. c:\program files\mycompany\myapplication\newfile.txt

the file in step 2 created reading out of specialfile.txt step 1.

my problem navigating murky combinations of wix settings enable me read session variables , have high enough privs write file out. has not been easy.

here solution:

<binary id="mycustomaction.ca.dll" sourcefile="path\to\mycustomaction.ca.dll" /> <customaction id="myactionsname"     return="check"     execute="deferred"     binarykey="mycustomaction.ca.dll"     dllentry="mycustomaction"     impersonate="no"/>      <customaction id="customaction1"         property="myactionsname"         value="installfolder=[get_this_from_your_directory_tag];sourcedir=[sourcedir]"/>  <installexecutesequence>      <custom action="customaction1" before="myactionsname" />     <custom action="myactionsname" before="installfinalize">not installed , not patch</custom> </installexecutesequence>        
  • impersonate="no" in order have enough privs write file
  • execute "deferred" in order have enough privs write file
  • the custom actions sequenced 1 runs before other. first action sets properties second action can read them. both need end running before="installfinalize" after files have been installed.

and in c# code, this:

string sourcedir = session.customactiondata["sourcedir"] string installfolder = session.customactiondata["installfolder"] 

additional helpful references:

this article , this article custom properties in deferred actions.

this article shows how read sourcedir without using session["sourcedir"] because custom action deferred.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -