ILMerge 与 NHIbernate 的困境

发布于 2024-11-28 11:00:25 字数 8350 浏览 2 评论 0原文

有人成功地将他们的程序集与 NHibernate v3.0 合并吗?

以下命令不起作用(抱怨程序集)

    ..\Tools\ILMerge /log:"merge.txt" 
    /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" 
    /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" 
out:SharpArchitecture.dll lib\NHibernate.Validator.dll "lib\Fluent NHibernate\NHibernate.dll" 
/keyfile:"SharpArch.Core\SharpArch.snk"

它需要以 3.5 框架为目标,以便它可以在 SharePoint 下运行。

这是日志

ILMerge version 2.11.502.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /log:merge.txt /lib:C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5 /lib:C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 /out:SharpArchitecture.dll lib\NHibernate.Validator.dll lib\Fluent NHibernate\NHibernate.dll /keyfile:SharpArch.Core\SharpArch.snk 
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727' for mscorlib.dll
Running on Microsoft (R) .NET Framework v2.0.50727
mscorlib.dll version = 2.0.0.0
The list of input assemblies is:
    lib\NHibernate.Validator.dll
    lib\Fluent NHibernate\NHibernate.dll
Trying to read assembly from the file 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\NHibernate.Validator.dll'.
Can not find PDB file. Debug info will not be available for assembly 'lib\NHibernate.Validator.dll'.
    Successfully read in assembly.
    There were no errors reported in NHibernate.Validator's metadata.
Trying to read assembly from the file 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\Fluent NHibernate\NHibernate.dll'.
    Successfully read in assembly.
    There were no errors reported in NHibernate's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
    NHibernate.Validator.PeKind = ILonly
    NHibernate.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'NHibernate'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
    AssemblyResolver: Did not find assembly in user-supplied directories.
    AssemblyResolver: Attempting framework directory.
    AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'System.Core'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Core' to 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll'. (Used a client-supplied directory.)
Can not find PDB file. Debug info will not be available for assembly 'System.Core'.
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'log4net'.
    AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'log4net'.
Resolved assembly reference 'log4net' to 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\log4net.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'Iesi.Collections'.
    AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Iesi.Collections' to 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\Fluent NHibernate\Iesi.Collections.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'System.ServiceModel'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.ServiceModel' to 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll'. (Used a client-supplied directory.)
Can not find PDB file. Debug info will not be available for assembly 'System.ServiceModel'.
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'System.Transactions'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
    AssemblyResolver: Did not find assembly in user-supplied directories.
    AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Transactions'.
Resolved assembly reference 'System.Transactions' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\System.Transactions.dll'. (Used framework directory.)
Using assembly 'NHibernate.Validator' for assembly-level attributes for the target assembly.
Merging assembly 'NHibernate.Validator' into target assembly.
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'NHibernate.Validator' being deleted from target assembly
Merging assembly 'NHibernate' into target assembly.
Duplicate type name: modifying name of the type '<>f__AnonymousType0`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType0`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType1`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType1`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType2`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType2`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType3`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType3`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType4`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType4`2'
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'NHibernate' being deleted from target assembly
Copying 1 Win32 Resources from assembly 'NHibernate.Validator' into target assembly.
ILMerge: Signing assembly with the key file 'SharpArch.Core\SharpArch.snk'.
    There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'SharpArchitecture.dll'.
An exception occurred during merging:
Unresolved assembly reference not allowed: NHibernate.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.VisitMethodCall(MethodCall call)
   at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitMethodBody(Method method)
   at System.Compiler.Ir2md.VisitMethod(Method method)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   at System.Compiler.Ir2md.VisitModule(Module module)
   at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
   at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

Has anyone successfully merged their assembly with NHibernate v3.0?

The following command doesnt work (complains about assemblies)

    ..\Tools\ILMerge /log:"merge.txt" 
    /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" 
    /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" 
out:SharpArchitecture.dll lib\NHibernate.Validator.dll "lib\Fluent NHibernate\NHibernate.dll" 
/keyfile:"SharpArch.Core\SharpArch.snk"

It needs to target the 3.5 framework so it can run under SharePoint.

here's the log

ILMerge version 2.11.502.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /log:merge.txt /lib:C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5 /lib:C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 /out:SharpArchitecture.dll lib\NHibernate.Validator.dll lib\Fluent NHibernate\NHibernate.dll /keyfile:SharpArch.Core\SharpArch.snk 
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727' for mscorlib.dll
Running on Microsoft (R) .NET Framework v2.0.50727
mscorlib.dll version = 2.0.0.0
The list of input assemblies is:
    lib\NHibernate.Validator.dll
    lib\Fluent NHibernate\NHibernate.dll
Trying to read assembly from the file 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\NHibernate.Validator.dll'.
Can not find PDB file. Debug info will not be available for assembly 'lib\NHibernate.Validator.dll'.
    Successfully read in assembly.
    There were no errors reported in NHibernate.Validator's metadata.
Trying to read assembly from the file 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\Fluent NHibernate\NHibernate.dll'.
    Successfully read in assembly.
    There were no errors reported in NHibernate's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
    NHibernate.Validator.PeKind = ILonly
    NHibernate.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'NHibernate'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
    AssemblyResolver: Did not find assembly in user-supplied directories.
    AssemblyResolver: Attempting framework directory.
    AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'System.Core'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Core' to 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll'. (Used a client-supplied directory.)
Can not find PDB file. Debug info will not be available for assembly 'System.Core'.
AssemblyResolver: Assembly 'NHibernate.Validator' is referencing assembly 'log4net'.
    AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'log4net'.
Resolved assembly reference 'log4net' to 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\log4net.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'Iesi.Collections'.
    AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Iesi.Collections' to 'C:\Dev\Dev\2010\Shared Libraries\Third Party\Sharp Architecture\lib\Fluent NHibernate\Iesi.Collections.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'System.ServiceModel'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.ServiceModel' to 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll'. (Used a client-supplied directory.)
Can not find PDB file. Debug info will not be available for assembly 'System.ServiceModel'.
AssemblyResolver: Assembly 'NHibernate' is referencing assembly 'System.Transactions'.
    AssemblyResolver: Attempting referencing assembly's directory.
    AssemblyResolver: Did not find assembly in referencing assembly's directory.
    AssemblyResolver: Attempting input directory.
    AssemblyResolver: Did not find assembly in input directory.
    AssemblyResolver: Attempting user-supplied directories.
    AssemblyResolver: Did not find assembly in user-supplied directories.
    AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Transactions'.
Resolved assembly reference 'System.Transactions' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\System.Transactions.dll'. (Used framework directory.)
Using assembly 'NHibernate.Validator' for assembly-level attributes for the target assembly.
Merging assembly 'NHibernate.Validator' into target assembly.
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'NHibernate.Validator' being deleted from target assembly
Merging assembly 'NHibernate' into target assembly.
Duplicate type name: modifying name of the type '<>f__AnonymousType0`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType0`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType1`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType1`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType2`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType2`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType3`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType3`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType4`2' (from assembly 'NHibernate') to 'NHibernate.<>f__AnonymousType4`2'
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'NHibernate' being deleted from target assembly
Copying 1 Win32 Resources from assembly 'NHibernate.Validator' into target assembly.
ILMerge: Signing assembly with the key file 'SharpArch.Core\SharpArch.snk'.
    There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'SharpArchitecture.dll'.
An exception occurred during merging:
Unresolved assembly reference not allowed: NHibernate.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.VisitMethodCall(MethodCall call)
   at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitMethodBody(Method method)
   at System.Compiler.Ir2md.VisitMethod(Method method)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   at System.Compiler.Ir2md.VisitModule(Module module)
   at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
   at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

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

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

发布评论

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

评论(1

顾挽 2024-12-05 11:00:25

尝试使用以下语法:

ILMerge.exe /log:"merge.txt" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" /lib:"FullPathToNHibernate" /lib:"FullPathToFluent NHibernate" /out:SharpArchitectureMerged.dll SharpArchitecture.dll NHibernate.Validator.dll NHibernate.dll /keyfile:"SharpArch.Core\SharpArch.snk"

基本上,
1. 将输出程序集传入/out
2. 主组件是 /out 开关之后的第一个参数
3. 使用 /lib 开关传递完整的库路径

或者,您可以提供引用程序集的完整文件路径,如下所示:

ILMerge.exe /log:"merge.txt" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" /out:SharpArchitectureMerged.dll SharpArchitecture.dll "FullPathToNHibernate\NHibernate.Validator.dll" "FullPathToFluent NHibernate\NHibernate.dll" /keyfile:"SharpArch.Core\SharpArch.snk"

我认为您当前的目录无法解析部分路径引用, 。

NHibernate.Validator.dll 也可能正在寻找 NHibernate.dll 的特定强命名版本

Try this syntax instead:

ILMerge.exe /log:"merge.txt" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" /lib:"FullPathToNHibernate" /lib:"FullPathToFluent NHibernate" /out:SharpArchitectureMerged.dll SharpArchitecture.dll NHibernate.Validator.dll NHibernate.dll /keyfile:"SharpArch.Core\SharpArch.snk"

Basically,
1. Pass the output assembly in /out
2. The primary assembly is the first parameter after the /out switch
3. Pass the full library paths using the /lib switch

OR you can provide the full file paths of the referenced assemblies like this:

ILMerge.exe /log:"merge.txt" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" /lib:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" /out:SharpArchitectureMerged.dll SharpArchitecture.dll "FullPathToNHibernate\NHibernate.Validator.dll" "FullPathToFluent NHibernate\NHibernate.dll" /keyfile:"SharpArch.Core\SharpArch.snk"

I'm thinking that your current directory does not resolve the partial path references, etc.

NHibernate.Validator.dll could also be looking for specific strongly named version of NHibernate.dll.

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