ILMerge + 本地化资源程序集

9
我正在使用ILMerge将一个包含1个exe和2个资源dll的项目创建为单个程序集应用程序:
  • \bin\Debug\test.exe
  • \bin\Debug\nl-BE\test.resources.dll
  • \bin\Debug\fr-FR\test.resources.dll
这是一个简单的测试项目,只有一个表单(Form1.cs),没有什么特别之处。我的目标是创建一个带有工作资源管理器的单个程序集应用程序(我已经阅读了关于如何做到这一点的信息ILMerge和本地化资源程序集单程序集多语言Windows Forms部署(ILMerge和卫星程序集/本地化)-可能吗?)。
编译项目后,我使用以下命令行参数运行ILMerge:
ilmerge /log:test.txt /target:winexe /copyattrs /allowdup /out:test_merged.exe 
"C:\projectdir\bin\Debug\test.exe" "C:\projectdir\bin\Debug\fr-FR\test.resources.dll" 
"C:\projectdir\bin\Debug\nl-BE\test.resources.dll"

如果我使用Reflector检查合并后的程序集的内容,我会在资源树节点下看到以下内容:
  • test.Form1.fr-FR.resources
  • test.Form1.fr-FR.resources
  • test.Form1.resources
  • test.Properties.Resources.resources
相比于fr-FR和nl-BE资源,我有两个fr-FR资源。这是因为资源dll具有相同的名称吗?结果是我只能在运行时获取fr-FR资源。
有什么想法吗?
更新(日志文件内容): (注意:二进制文件以“loc_”为前缀,出于清晰起见,我在之前的帖子中将它们省略了)
ILMerge version 2.10.526.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged.exe c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll 
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework\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:
    c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe
    C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll
    C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll
Trying to read assembly from the file 'c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe'.
    Successfully read in assembly.
    There were no errors reported in loc_test's metadata.
Trying to read assembly from the file 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll'.
Can not find PDB file. Debug info will not be available for assembly 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll'.
    Successfully read in assembly.
    There were no errors reported in loc_test.resources's metadata.
Trying to read assembly from the file 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll'.
Can not find PDB file. Debug info will not be available for assembly 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll'.
    Successfully read in assembly.
    There were no errors reported in loc_test.resources's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
    loc_test.PeKind = ILonly
    loc_test.resources.PeKind = ILonly
    loc_test.resources.PeKind = ILonly
All input assemblies have a compatible PeKind value.
Merging assembly 'loc_test' into target assembly.
Merging assembly 'loc_test.resources' into target assembly.
Merging assembly 'loc_test.resources' into target assembly.
Merging assembly-level attributes from assembly 'loc_test' into target assembly.
Copying 2 Win32 Resources from assembly 'loc_test' into target assembly.
Transferring entry point 'loc_test.Program.Main' from assembly 'loc_test' to assembly 'loc_test_merged'.
    There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'loc_test_merged.exe'.
AssemblyResolver: Assembly 'System' is referencing assembly 'System.Configuration'.
    AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Configuration'.
Resolved assembly reference 'System.Configuration' to 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll'. (Used referencing Module's directory.)
Location for referenced assembly 'System.Windows.Forms' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll'
    There were no errors reported in  System.Windows.Forms's metadata.
Location for referenced assembly 'System' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll'
    There were no errors reported in  System's metadata.
Location for referenced assembly 'mscorlib' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll'
    There were no errors reported in  mscorlib's metadata.
Location for referenced assembly 'System.Drawing' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll'
    There were no errors reported in  System.Drawing's metadata.
ILMerge: Done.

更新:项目代码的zip文件可在http://www.filedropper.com/loctest上下载。
更新:信不信由你,但如果我将ILMerge分为两个步骤执行,它就会工作!
ilmerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged.exe "c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe" "C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll"

ilmerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged_2.exe loc_test_merged.exe "C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll"

这可能是什么原因呢?
谢谢, Janiek

看起来你需要按照这个解决方案中提到的步骤去操作:https://dev59.com/Weo6XIcBkEYKwwoYTzEw - Cameron Jordan
我已经阅读了那个问题。它详细介绍了ComponentResourceManager类,该类只有在ILMerge首先正确嵌入必要的资源时才能很好地完成其工作。 - Janiek Buysrogge
请提供日志文件test.txt的输出。 - user474407
如果您已经找到了问题的答案,请将其作为答案提供并接受它。 - Bobby
1个回答

4

虽然我不知道为什么ILMerge需要在两个步骤中正确集成程序集,但目前这似乎是唯一的解决方案。请查看我在问题中最后的编辑,以了解我是如何做到这一点的。

不过我仍然好奇为什么它无法在一个步骤中完成...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接