如何向wix安装项目添加自定义操作

我的解决方案中有两个项目:

1)。 自定义操作类(CustomAction)

2)。 Wix安装项目(TestSetup)

CustomAction项目中有CustomAction.cs:

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using Microsoft.Deployment.WindowsInstaller; namespace CustomAction { public class CustomActions { [CustomAction] public static ActionResult CustomAction1(Session session) { File.Create(@"c:\installed.txt"); return ActionResult.Success; } } } 

Product.wxs:

                                 

安装项目构建没有问题,但是当我尝试运行它时,我收到一条错误消息:“此Windows Installer程序包存在问题。无法运行此安装所需的DLL。请联系您的支持人员或包装供应商“

我认为这是因为二进制源文件值不正确。 你会说明如何解决它吗?

问题是您的CustomAction方法名称“CustomAction1”与您提到的“DLLEntry”值不匹配(DllEntry =’CustomAction’)。 你错过了“1”:)

  

你应该这样写: –

  

其中CustomAction1是您的CustomAction名称..