无法在MSI中运行Wix自定义操作

Nat*_*han 8 windows-installer custom-action wix

我正在尝试为我的Wix安装创建一个自定义操作,它只是不起作用,我不确定为什么.

这是适当的Wix文件中的位:

<Binary Id="INSTALLERHELPER" SourceFile=".\Lib\InstallerHelper.dll" />
<CustomAction Id="HelperAction" BinaryKey="INSTALLERHELPER" DllEntry="CustomAction1" Execute="immediate" />
Run Code Online (Sandbox Code Playgroud)

这是我的自定义操作的完整类文件:

using Microsoft.Deployment.WindowsInstaller;

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

      return ActionResult.Success;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

该操作由UI中的按钮按下(现在):

  <Control Id="Next" Type="PushButton" X="248" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" >
      <Publish Event="DoAction" Value="HelperAction">1</Publish>
  </Control>
Run Code Online (Sandbox Code Playgroud)

当我运行MSI时,我在日志中收到此错误:

MSI (c) (08:5C) [10:08:36:978]: Connected to service for CA interface.
MSI (c) (08:4C) [10:08:37:030]: Note: 1: 1723 2: SQLHelperAction 3: CustomAction1 4: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action SQLHelperAction, entry: CustomAction1, library: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 
MSI (c) (08:4C) [10:08:38:501]: Product: SessionWorks :: Judge Edition -- Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action SQLHelperAction, entry: CustomAction1, library: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 

Action ended 10:08:38: SQLHelperAction. Return value 3.
DEBUG: Error 2896:  Executing action SQLHelperAction failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: SQLHelperAction, , 
Run Code Online (Sandbox Code Playgroud)

它给我的两个错误代码或消息都不足以告诉我什么是错的.或许我只是不明白他们说的是错的.

起初我以为可能是因为我使用的是Wix 3.5,所以为了确保我尝试使用Wix 3.0,但我得到了同样的错误.

关于我做错了什么的任何想法?

Kni*_*rmy 8

对于自定义操作程序集,您需要一个配置文件并将useLegacyV2RuntimeActivationPolicy属性设置为true.确保命名配置文件CustomAction.config.如果你不这样做,它将无法正常工作.我假设您正在运行.NET 4 Framework.

有关详细信息,请参见此处 另外,正如AntonyW已经指出的那样,fuslogvw.exe在这种情况下非常有用.


Kir*_*121 8

而不是引用.dll引用.CA.dll,它对我有用.

  • 这正是我发生的事情。我创建了一个名为“ Company.CA”的项目,该项目产生了“ Company.CA.dll”。但是后来WiX将所有内容塞入“ Company.CA.CA.dll”中,我没有注意到。我浪费了整整一个小时! (2认同)

Bry*_*der 6

通过启动的自定义操作DoAction无法写入日志文件.

当我第一次开始使用WiX时,这也让我很困惑.

如果您想查看正在发生的事情,可以System.Diagnostics.Debugger.Launch()在自定义操作的开头使用.这将提示您将Visual Studio附加到进程,以便您可以对其进行调试.

  • Debugger.Launch()没有为我做任何事情. (3认同)