有人在使用 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/