Visual Studio 安装程序项目:自定义操作 -> 未找到入口点

Visual Studio Installer Project: Custom Action -> entry point not found

我尝试向安装程序项目添加自定义操作。我使用以下代码添加了一个自定义操作项目:

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

      return ActionResult.Success;
    }
  }

在我的安装程序项目中,我添加了对 CustomAction_project 的引用,并在自定义操作 -> 安装中添加了以下条目:

名称:CustomAction 的主要输出(活动) 入口点:CustomAction1 安装程序类:错误 SourcePath: CustomAction.dll

的路径

现在,如果我尝试构建我的安装程序项目,我会收到以下错误:

ERROR: Entry point 'CustomAction1' not found in module 'PATH\CustomAction.dll' for custom action 'Primary output from CustomAction (Active)'.

您已经构建了一个用于 WiX 设置的托管代码自定义操作项目。如果您使用本机 Visual Studio 安装程序项目,则需要安装程序 class 自定义操作。这些可能有帮助:

https://msdn.microsoft.com/en-us/library/vstudio/d9k65z2d(v=vs.100).aspx

http://www.c-sharpcorner.com/uploadfile/ddoedens/usinginstallerclassestoeasedeploymentinvs.net12012005061649am/usinginstallerclassestoeasedeploymentinvs.net.aspx

http://vbcity.com/forums/t/145818.aspx

基本上,您将一个安装程序 class 添加到您的项目,并覆盖安装方法。

如果您想使用来自 Microsoft.Deployment.WindowsInstaller 的 CustomActions(不是安装程序 Class) 你需要:

  1. here 安装 wix 工具集。
  2. 在 VS 中创建一个新的 class 项目
  3. 参考 %WiX%SDK\Microsoft.Deployment.WindowsInstaller.dll
  4. 创建一个 class 喜欢 this
  5. 编译。
  6. 编译的结果应该是 projectName.dll 和 projectName.CA.dll,projectName.CA.dll 必须像这样包含在您的安装项目中:

安装愉快...:)