简体   繁体   中英

WIX c# CustomAction, what am I doing wrong?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM