To be more specific:
I'm using a managed code custom action (C#).
// this works up to....
public static int DoMyAction(long handle)
{
// get the msi's handle
IntPtr msiHandle = new IntPtr(handle);
try
{
// get the installationpath
string installationPath = MsiHandler.GetProperty(msiHandle,
"INSTALLLOCATION") + @"\";
installationPath = installationPath.Replace(@"\\", @"\");
// get the path to the xml file
string filePath = installationPath + @"myfile.xml";
//... here. It fails here (file not found)
try
{
// open the xml file and get the root
XmlDocument doc = new XmlDocument();
resources.Load(filePath);
Are you saying that the path to the file is different during deferred
execution to when the file is actually installed?
You really shouldn't be able to access any properties you need in a deferred
custom action. I do something similar in our installer, I lay down a config
file, open it up and replace some variables with a custom action. I use the
following immediate custom action to write to the CustomActionData property,
then in the deferred custom action, I access that property and use it to
read the file.
<CustomAction Id="SetDeferredProp" Property="DeferredCustomActionName"
Value="[FILEDIR]" />
Dana
On 11/14/06, carlldev <[EMAIL PROTECTED]> wrote:
>
>
> Thanks for your quick reply.
>
> I tried setting the customaction to deferred but that also doesn't work. I
> don't know how to access files through the CustomActionData property.
> I don't have any problems accessing property values either - I can access
> the properties I need. I just can't touch any files.
>
> Maybe I can try it a different way - by including the xml file as a binary
> inclusion and opening that? Then it is technically not an installed file.
> But I can't find a good example of doing that either. Most examples just
> execute binary files.
>
> Any more ideas?
>
>
> Dana Gutride wrote:
> >
> > Two possible ideas come to mind. 1) Is your custom action scheduled to
> > run
> > as a deferred custom action? 2) Depending on when you are attempting
> to
> > execute this custom action, you might be having some difficulty
> accessing
> > the msi properties. Deferred custom actions have access to only a very
> > limited number of properties (search for CustomActionData). The custom
> > action you are describing would need to be deferred and use the
> > CustomActionData property if it's accessing any installed files.
> >
> > See this section of the tutorial for more info:
> > http://www.tramontana.co.hu/wix/lesson3.php#3.6
> >
> > Dana
> >
> >
> > On 11/14/06, carlldev <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >> Hi there,
> >>
> >> I have a working Custom Action that reads an installed XmlFile and
> >> executes
> >> a command line a number of times with parameters extracted from the
> >> xmlfile.
> >>
> >> The code works fine if I put it after InstallFinalize but that means if
> >> the
> >> command line execution fails there is no way to rollback the
> >> installation.
> >>
> >> I have added debugging to the code and it reveals this:
> >> 'Could not find a part of the path 'C:\Program
> >> Files\Product\Resources.xml'.'.
> >>
> >> But since the code is being executed after InstallFiles the xmlfile
> >> should
> >> be there.
> >>
> >> The custom action (in Wix) looks like this:
> >> <CustomAction Id="DoMyAction" BinaryKey="CustomActions"
> >> DllEntry="DoMyAction" />
> >> <Custom Action="DoMyAction" After="InstallFiles">NOT Installed</Custom>
> >>
> >> Any help would be appreciated.
> >> Thanks
--
View this message in context:
http://www.nabble.com/Managed-Code-Custom-Action---Reading-Xml-File-tf2628948.html#a7341265
Sent from the wix-devs mailing list archive at Nabble.com.
-------------------------------------------------------------------------
SF.net email is sponsored by: A Better Job is Waiting for You - Find it Now.
Check out Slashdot's new job board. Browse through tons of technical jobs
posted by companies looking to hire people just like you.
http://jobs.slashdot.org/
_______________________________________________
WiX-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-devs