ILMerge DLL:程序集未正确合并,仍列为外部引用

发布于 2024-08-12 13:33:16 字数 315 浏览 4 评论 0原文

在 .NET C# 工具的构建过程中,我一直在使用 ILMerge 将程序集合并到单个 exe 中。

我最近添加了一个新的类库,现在 ILMerge 失败了。我记得告诉它合并到新的 DLL 中!

它现在给了我这个错误,我不太明白:

ILMerge.Merge:程序集 “DataObjects”未合并到 正确。它仍然被列为 目标中的外部参考 组装。

我使用“项目”引用完成的所有程序集引用,过去都没有失败。

任何人都可以为我解释这个错误,或者建议一个解决方法吗?

In the build process for a .NET C# tool, I have been using ILMerge to merge the assemblies into a single exe.

I added a new class library recently, and now the ILMerge is failing. I have remembered to tell it to merge in the new DLL!

It is now giving me this error, which I don't really understand:

ILMerge.Merge: The assembly
'DataObjects' was not merged in
correctly. It is still listed as an
external reference in the target
assembly.

All of the assembly references I have done using 'project' references, and it has not failed in the past.

Can anyone explain this error for me, or suggest a workaround please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

天邊彩虹 2024-08-19 13:33:16

我必须使用 /close 参数。根据官方文档

关闭

当在调用 Merge 之前设置此值时,
那么“传递闭包”
计算并添加输入组件
到输入程序集列表。一个
装配体被认为是
传递闭包,如果是
直接引用或
间接地,从最初的其中之一
指定的输入组件,它有
对其中之一的外部引用
输入组件,或其中之一
具有此类引用的程序集。
很复杂,但这就是生活......

I had to use the /closed argument. According to the official docs:

Closed

When this is set before calling Merge,
then the "transitive closure" of the
input assemblies is computed and added
to the list of input assemblies. An
assembly is considered part of the
transitive closure if it is
referenced, either directly or
indirectly, from one of the originally
specified input assemblies and it has
an external reference to one of the
input assemblies, or one of the
assemblies that has such a reference.
Complicated, but that is life...

鹿港小镇 2024-08-19 13:33:16

当我尝试发布将所有输出合并到单个程序集的 Web 应用程序时,我收到了类似的错误消息:

合并程序集时发生错误:ILMerge.Merge:目标程序集将自身列为外部引用。

如果您要合并的程序集名称与 Properties > 下的 Web 应用程序的程序集名称相匹配,就会发生这种情况。应用程序。更改输出程序集名称应该可以修复它。

I got a similar error message when trying to publish a web app that merged all outputs to a single assembly:

An error occurred when merging assemblies: ILMerge.Merge: The target assembly lists itself as an external reference.

This happens if the assembly name you are merging to matches the assembly name of the web application under Properties > Application. Changing the output assembly name should fix it.

寄离 2024-08-19 13:33:16

我收到此错误,它指向我正在合并到单个 dll 中的 Microsoft.Xrm.Sdk 引用。当我设置另一个引用 Microsoft.Xrm.Sdk.Deployment 也合并到 dll 中时,问题得到解决。有趣的是,在一个单独的项目中,我进行了第一个参考合并,而第二个部署 dll 没有合并&它根本没有抱怨。

I got this error and it pointed to the Microsoft.Xrm.Sdk reference which I was merging into the single dll. The problem was fixed when I set another reference, Microsoft.Xrm.Sdk.Deployment to merge into the dll as well. Funny thing is in a separate project I had the 1st reference merging and the 2nd deployment dll not merging & it did not complain at all.

淡看悲欢离合 2024-08-19 13:33:16

这正是@HughJeffner 作为图像的答案。我花了一段时间&有些人试图复制这些说明。

位置字段不应相同。

This is exactly @HughJeffner's answer as an image. It took me a while & some tries to replicate the instructions.

Locations of the fields that should NOT be identical.

╰ゝ天使的微笑 2024-08-19 13:33:16

发布时从配置中选择“不合并”,然后发布项目

While publishing select 'Do not merge' from configure and than publish the Project

栖竹 2024-08-19 13:33:16

我收到了 System.Memory.dll 的错误,这很奇怪。在合并和部署 Dynamics CRM 插件 dll 的上下文中。

我实际上只是忽略了它并部署了我的合并 DLL... 相信 Dynamics CRM 的插件上下文会在部署时提供它。

即使出现有关 System.Memory.dll 的错误,MergedPlugin.dll 仍然会构建。所以我只是将该插件部署到 CRM,并且它起作用了。

I got this error for System.Memory.dll which was odd. In the context of merging and deploying a Dynamics CRM Plugin dll.

I actually just ignored it and deployed my Merged DLL... trusting that Dynamics CRM's Plugin context would provide it when it's deployed.

The MergedPlugin.dll was still built even with the error about System.Memory.dll. So I just deployed the Plugin to CRM, and it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文