c# - 有没有办法将 pdb 文件与 ilmerge 合并?

标签 c# .net ilmerge

出于各种原因,我们使用 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="&quot;..\..\Libraries\Ilmerge.exe&quot; /copyattrs /allowMultiple /out:&quot;@(MainAssembly)&quot; &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
    <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/

相关文章:

c# - 如何创建动态数量的对象?设计模式帮助

c# - yield return 语句如何不返回任何元素?

c# - 从列表中排除一个项目(按索引),并采取所有其他

.net - 后台工作线程导致 UI 挂起

.net - 如何使用 ILMerge 将 XML 文档文件与 DLL 合并?

.net - 如何在 AfterBuild 中将 ILMerge 与 .NET 4.5 结合使用?

c# - 静态与实例方法性能 C#

c# - 具有 TimeSpan 数据类型的 DataView RowFilter

c# - 使用 LINQ 进行“智能”分组

c# - 在 .NET v4+ 程序集上嵌入\合并 .NET v1 程序集