You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WixSharp Managed Actions编译失败:无法识别自定义动作入口点

WixSharp自定义动作编译报错问题排查

感谢WixSharp的优秀开发工作。我始终无法成功编译单个WixSharp自定义动作,以下是精简后的测试代码,构建时始终报错,代码本身无明显问题。

报错信息1:

Severity Code Description Project File Line Suppression State Details
Error (active) Invalid argument: No CA or UI entry points found in module: C:\source\repos\Solution1\WixSharpInstall\WixSharpInstall.exe WixSharpInstall C:\source\repos\Solution1\WixSharpInstall\EXEC 1

报错信息2:

Severity Code Description Project File Line Suppression State Details
Error (active) MSB3073 The command "cd .

set ide=true
"C:\source\repos\Solution1\WixSharpInstall\bin\Debug\net472\WixSharpInstall.exe"" exited with code -532462766. WixSharpInstall C:\source\repos\Solution1\WixSharpInstall\WixSharpInstall.csproj 28

测试代码:

using System;
using WixSharp;
using WixToolset.Dtf.WindowsInstaller;

namespace WixSharpInstall
{
    internal class Program
    {
        static void Main()
        {
            var project = new Project("My Proj",
                new ManagedAction(CATest, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed)
                )
            {
                Platform = Platform.x64,
                GUID = new Guid("23ba4376-a6c1-4bec-af74-16c672702d9d"),
            };
            project.BuildMsi();
        }

        [CustomAction]
        static ActionResult CATest(Session session)
        {
            return ActionResult.Success;
        }
    }
}

我实际的项目包含目录、文件、注册表项、防火墙规则等其他结构,这些功能均正常,但自定义动作始终无法编译,请问问题出在哪里?


问题原因及解决方法

问题核心是自定义动作方法的访问权限不足:你的CATest方法默认是private(类为internal时,未显式声明修饰符的方法默认为private),而WixSharp需要自定义动作方法为public才能识别为合法的入口点。

解决步骤:

  • 将CATest方法的访问修饰符改为public
  • 清理项目的bin和obj目录,避免旧缓存干扰
  • 确保WixSharp与WixToolset.Dtf.WindowsInstaller的NuGet包版本一致,避免版本冲突

修改后的关键代码片段:

[CustomAction]
public static ActionResult CATest(Session session) // 显式声明public
{
    return ActionResult.Success;
}

内容的提问来源于stack exchange,提问作者Vector

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 00:38:14