出于各种原因,我们使用 ilmerge 将所有应用程序程序集放入一个文件中,因此用户只需处理一个文件。不幸的是,似乎没有办法将 .pdb 文件与程序集合并。有人知道解决这个问题的方法吗?
最佳答案
好吧,我想出了这个,虽然花了一段时间。
那篇文章的/ndebug 正好倒过来。
来自 ILMerge 附带的发行说明(ILMerge.doc,强调我的):
2.8 DebugInfo public bool DebugInfo { get; set; } When this is set to true, ILMerge creates a .pdb file for the output assembly and merges into it any .pdb files found for input assemblies. If you do not want a .pdb file created for the output assembly, either set this property to false or else specify the /ndebug option at the command line. Default: true Command line option: /ndebug
解决方案是专门不在您的命令行上设置该标志。默认情况下,ILMerge 将合并 pdb 文件。确保源程序集的所有 pdb 文件与其相关联的 dll 位于同一目录中,以便 ILMerge 可以找到它们。 (我们正在使用项目引用并拥有一个 ILMerge 项目,它负责满足这一要求。)
这是我的 ILMerge csproj 文件中的相关部分。
<Target Name="AfterBuild">
<CreateItem Include="@(ReferencePath)" Condition="'%(CopyLocal)'=='true'">
<Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
</CreateItem>
<Exec Command=""..\..\Libraries\Ilmerge.exe" /copyattrs /allowMultiple /out:"@(MainAssembly)" "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
为了完整起见,我使用的是最新版本的 ilmerge.exe:版本 2.10.219.0,最后修改日期为 2/19/2010 9:49 AM
关于c# - 有没有办法将 pdb 文件与 ilmerge 合并?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1439721/