[英]Visual Studio C# MSBuild.ILMerge.Task problem with The assembly is not marked as containing only managed code
我有 2 个项目的解决方案,例如:
我想在 MainDLL 中合并 LibraryDLL。 我的应用程序只需要导入一个文件作为插件。 我下载了 NUGet 打包:
设置后,当我按下构建时,我收到以下错误:
ILMerge.Merge: The assembly 'ChilkatDotNet4' is not marked as containing only managed code.
(Consider using the /zeroPeKind option -- but read the documentation first!)
我没有直接使用它,也不需要它,但它可能被两个项目中其他引用的 dll 引用(我不需要包含它,因为应用程序已经有了它)。 如何避免这个问题? 我试图设置标志:
<!-- See ILMerge documentation -->
<ILMergeAllowZeroPeKind></ILMergeAllowZeroPeKind>
真或假,但没有任何改变
Visual Studio C# MSBuild.ILMerge.Task 问题 程序集未标记为仅包含托管代码
我认为您的LibraryDLL是 c++ 本机动态库项目,ILMerge 无法处理包含本机代码的程序集。
您必须在使用前在运行时提取 dll,或运送 dll。
建议
1)我认为您已经编写了构建前事件或构建后事件来运行此命令,因此请在您的命令中添加/zeroPeKind
。
像ilmerge /target:xxxx /zeroPeKind /out:xxxxx xxxxxxxxx
2)此外,您还可以尝试此解决方法(使用 DllImport)来解决您的问题。
使用 /zeroPeKind 对我来说是不成功的(并不意味着它的错误方式)。 我也无法重建这个本机 c++ 库,因为它来自外部提供商。
检查后https://github.com/emerbrito/ILMerge-MSBuild-Task/wiki
使用复制本地 = True 合并程序集
我已将所有其他 References 属性设置 Copy Local 更改为 false。
我离开 Copy Local = true 只是为了引用我想与我的主项目合并的共享项目库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.