[wix-users] (no subject)

Shintaro Takechi devst119 at gmail.com
Tue Jul 26 17:43:25 PDT 2016


Hi

I have very basic WiX Custom Action and .wxs file that is only running that
custom action.

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="WiXFileCopyTest" Language="1033"
Version="1.0.0.0" Manufacturer="testCompany"
UpgradeCode="012423ee-b380-4fce-9c79-1cc8fe6c5923">
    <Package InstallerVersion="200" Compressed="yes"
InstallScope="perMachine" />
         <Binary Id="DirectoryTreeCopyWiXCustomActionDLL"
SourceFile="$(var.DirectoryTreeCopyWiXCustomAction.TargetDir)DirectoryTreeCopyWiXCustomAction.CA.dll"
/>

        <CustomAction Id="CA_DirectoryTreeCopy"
                      BinaryKey="DirectoryTreeCopyWiXCustomActionDLL"
                      DllEntry="CopyDirectoryTree"
                      Execute="immediate"
                      Return="check"/>
         <InstallExecuteSequence>
        <Custom Action="CA_DirectoryTreeCopy"
                After="InstallInitialize"/>
        </InstallExecuteSequence>
    </Product>
    </Wix>

Following is the C# implementation of custom action.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Deployment.WindowsInstaller;
    using System.IO;

    namespace DirectoryTreeCopyWiXCustomAction
    {
        public class CustomActions
        {
            [CustomAction]
            public static ActionResult CopyDirectoryTree(Session session)
            {
                session.Log("Begin CopyDirectoryTree");

                var EtapUserPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"test\\");
                var SourcePath = Path.Combine(EtapUserPath, "test 1.1\\");
                var DestinationPath = Path.Combine(EtapUserPath, "test
1.2\\");

                //Now Create all of the directories
                foreach (string dirPath in
Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories))
                    Directory.CreateDirectory(dirPath.Replace(SourcePath,
DestinationPath));

                //Copy all the files & Replaces any files with the same name
                foreach (string newPath in Directory.GetFiles(SourcePath,
"*.*", SearchOption.AllDirectories))
                    File.Copy(newPath, newPath.Replace(SourcePath,
DestinationPath), true);

                return ActionResult.Success;
            }
        }
    }


Of course, I do have the references on my wix project set to the
DirectoryTreeCopyWiXCustomAction project, so that is out of equation.

I have tested the code so I know that the main C# code is functioning.

I opened the result msi and saw that CustomAction exist in the msi.

When I output the log, I do not see anywhere that states "Begin
CpyDirectoryTree".

I just cannot figure out how to make the custom action work.

Seems extremely straight forward, but it is not working for me.

Thank you


More information about the wix-users mailing list