ILMerge对NHIbernate感到困扰

时间:2011-08-04 16:29:11

标签: nhibernate sharepoint ilmerge

有没有人成功地将他们的程序集与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)

1 个答案:

答案 0 :(得分:0)

请尝试使用以下语法:

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.将输出组件输入/输出
2.主程序集是/ out开关后的第一个参数 3.使用/ lib开关传递完整的库路径

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

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。