WIX 中的托管 (C#) 自定义操作不起作用(错误代码 1154)
我正在开发一个自定义操作来将相同的文件安装到多个文件夹中(在运行时确定)。
自定义操作驻留在 Wix C# 自定义操作项目中。 它的代码如下所示:
public class CustomActions
{
[CustomAction]
public static ActionResult InstallToTrunks(Session session)
{
// some logic
}
}
相关的 WIX 标记如下所示:
<Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.dll' />
<CustomAction Id='InstallToTrunks' BinaryKey='CustomActions' DllEntry='InstallToTrunks' Execute='deferred' Return='check'/>
<InstallExecuteSequence>
<Custom Action='InstallToTrunks' After='InstallInitialize'></Custom>
</InstallExecuteSequence>
但是,当我尝试运行安装程序时,它失败了,日志显示: CustomAction InstallToTrunks 返回实际错误代码 1154(请注意,如果翻译发生在沙箱内,这可能不是 100% 准确)
任何帮助将非常受欢迎。 或者,如果您对如何在没有 CustomActions 的情况下实现我想要做的事情(将相同的文件安装到只能在重新启动时确定的多个文件夹中)有建议,那也会很有帮助。
谢谢。
I'm developing a Custom Action to install the same file into multiple folders(that are determined at runtime).
The custom action resides inside a Wix C# Custom Action Project.
It's code looks like this:
public class CustomActions
{
[CustomAction]
public static ActionResult InstallToTrunks(Session session)
{
// some logic
}
}
The relevant WIX markup looks like this:
<Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.dll' />
<CustomAction Id='InstallToTrunks' BinaryKey='CustomActions' DllEntry='InstallToTrunks' Execute='deferred' Return='check'/>
<InstallExecuteSequence>
<Custom Action='InstallToTrunks' After='InstallInitialize'></Custom>
</InstallExecuteSequence>
However, when I try to run the setup, it fails, and log says:
CustomAction InstallToTrunks returned actual error code 1154 (note this may not be 100% accurate if translation happened inside sandbox)
Any help would be very welcome.
Alternatively, if you have a suggestion on how to achieve what I'm trying to do(install same file into multiple folders that can be determined only at retuntime) without CustomActions, that would be helpful too.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您似乎正在引用自定义操作程序集,而不是自定义操作 DLL。这些自定义操作项目会生成一个名为 xxxx.CA.dll 的非托管自定义操作 DLL,其中包含自定义操作程序集及其依赖项的压缩副本。
尝试:
It looks like you're referencing the custom action assembly, rather than the custom action DLL. Those custom action projects produce an unmanaged custom action DLL called xxxx.CA.dll which contains a compressed copy of your custom action assembly and its dependencies.
Try:
WiX 已通过 CopyFile 元素 支持此功能。
基本上,您为要制作的每个副本创建一个 CopyFile 元素。然后,您可以将每个副本的 DestinationProperty 属性设置为自定义属性。这些属性可以在安装过程中动态设置。
但是,如果您想使用自定义操作,有多种解决方案:
自定义 .NET DLL 不是支持。如果您有 .NET DLL,请将其转换为安装程序类操作。
WiX already supports this through CopyFile element.
Basically, you create a CopyFile element for each copy you want to make. You can then set the DestinationProperty attribute to a custom property for each copy. These properties can be set dynamically during install.
However, if you want to use a custom action, there are several solutions:
Custom .NET DLLs are not supported. If you have a .NET DLL, convert it to an installer class action.
尽管您接受了答案并且似乎您将采用自定义操作方式,但我想提醒您注意,CopyFile 方法是推荐和支持的执行您在场景中描述的此类操作的方法。如果您不确切知道要复制到的文件数量和位置,您可以在安装期间通过立即自定义操作将临时行添加到 CopyFile 表中。通过这种方式,您可以向 Windows Installer 提供具体的操作指示,并让它完成其工作。
Although you accepted the answer and it seems that you'll go the custom action way, I would point your attention that CopyFile approach is the recommended and supported way of doing this kind of things you describe in your scenario. If you don't know exactly the number of files and locations to copy to, you can add temporary rows to the CopyFile table during install time in an immediate custom action. This way you give Windows Installer exact instructions of what to do and let it do its job.