.net - 构建时出现 ILMerge 错误

标签 .net msbuild build ilmerge

有人在使用 IlMerge 时遇到过此错误吗?我正在尝试使用 4.0 Framework 合并 .NET 项目的一些程序集。

ILMerge/log/lib:..\Libraries/targetplatform:v4/internalize:..\SolutionFiles\CJCommon.exclude/ndebug/out:bin\Release\Common.dll obj\Release\Common.dll C:\开发\CJCommon\Libraries\FluentNHibernate.dll C:\Development\CJCommon\Libraries\HibernatingRhinos.Profiler.Appender.dll C:\Development\CJCommon\Libraries\Iesi.Collections.dll C:\Development\CJCommon\Libraries\log4net。 dll C:\Development\CJCommon\Libraries\Microsoft.Practices.ServiceLocation.dll C:\Development\CJCommon\Libraries\NHibernate.ByteCode.CaSTLe.dll C:\Development\CJCommon\Libraries\NHibernate.dll C:\Development\CJCommon\Libraries\NHibernate.Linq.dll C:\Development\CJCommon\Libraries\StructureMap.dll

将平台设置为“v4”,对 mscorlib.dll 使用目录“C:\Windows\Microsoft.NET\Framework64\v2.0.50727..\v4.0.20107”

合并时发生异常:

未将对象引用设置为对象的实例。

 at System.Compiler.CoreSystemTypes.GetSystemAssembly(Boolean doNotLockFile, Boolean getDebugInfo)
 at System.Compiler.CoreSystemTypes.Initialize(Boolean doNotLockFile, Boolean getDebugInfo)
 at System.Compiler.SystemTypes.Initialize(Boolean doNotLockFile, Boolean getDebugInfo)
 at ILMerging.ILMerge.Merge()
 at ILMerging.ILMerge.Main(String[] args)

C:\Program Files (x86)\MSBuild\Ilmerge.CSharp.targets(8,5):错误 MSB3073:命令“”C:\Program Files (x86)\Microsoft\Ilmerge\Ilmerge.exe”/log/lib:"..\Libraries"/targetplatform:v4/internalize:./.exited with code 1...

...

========== 全部重建:3 成功,1 失败,0 跳过 ==========

最佳答案

在目标平台中包含 4.0 Framework 的路径,并确保使用引号。例如,从 PowerShell:

.\ILMerge /out:Merged.dll /targetplatform:'v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319' .\Assembly1.dll .\Assembly2.dll

关于.net - 构建时出现 ILMerge 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3106855/

相关文章:

java - Intellij fat one jar 工件不会生成工作输出

c# - .Net 多个客户端和中央服务器之间的数据同步

c# - MVC3架构不需要DAL层吗?

msbuild - 如何将 MSB3245(无法解析引用)警告视为错误?

.net - 在运行时运行 MSBuild

scala - sbt 更新未解析存储库中的最新工件

build - 无法使用带有 tfs 13 的构建自动修改 .csproj 文件

c# - 如何让 ConfigurationManager 从多个文件加载应用程序设置?

c# - 无法读取 X509Certificate2 上的私钥

.net - 如何在 csproj 中使用 dotnet-pack --version-suffix?