views:

193

answers:

1

I'm using VS2010 and WIX 3.5.

1) I created WIX Setup Project.

2) Then I added to the solution C# custom action project and called it 'CustomActions'

 namespace CustomActions
 {
   public static class CustomActions
   {
     [CustomAction]
     public static ActionResult CustomAction1(Session session)
     {
         Debugger.Break();
         MessageBox.Show("It works");
         session.Log("Begin CustomAction1");
         return ActionResult.Success;
     }
   }
 }

3) Then I compiled CustomActions project and added reference to it from my setup project.

4) And finally put into .wxs file:

 <Binary Id="CustomActions"  SourceFile="$(var.CustomActions.TargetDir)$(var.CustomActions.TargetName).CA.dll"/>

 <CustomAction Id="CustomAction1" BinaryKey="CustomActions" DllEntry="CustomAction1" Execute="immediate" />

That doesn't work. What am I doing wrong? Please help me.

+1  A: 

You also need to schedule the custom action to run

   <InstallUISequence>
      <Custom Action="CustomAction1" After="AppSearch"/>
   </InstallUISequence>

Also you have to be aware that running in the MSI sandbox limits alot of things. I don't believe your call to MessageBox.Show will work. You'll have to rely on the session logging instead.

Rob McCready
The call to MessageBox.Show() will work if he is referencing the name space System.Windows.Forms and also has added the directive 'Using System.Windows.Forms'
Mario
I gave it a test and it does indeed seem to work. I don't believe its a good idea, but any which way that gets the job done. :)
Rob McCready