我在我的项目 c# 项目中使用 CefSharp 程序集作为参考。即使在“高级构建设置”对话框中将“调试信息”设置为“无”之后,我也会在输出文件夹中为所有 CefSharp 相关文件生成 PDB 文件。
无论如何要停止在我的输出文件夹中生成它们。
CefSharp
nuget 包故意包含 pdb 文件。包含它们的决定早于 Nuget.org 能够托管 snupkg 文件并且在 dll 中嵌入符号之前。对于开源项目,能够轻松访问有意义的堆栈跟踪符号非常重要。
您可以使用
target
文件中的 proj
从构建输出中排除 pdb(和 xml)文件。以下应排除 pdb
和 xml
文件。请注意扩展名只检查文件扩展名,您可以轻松地调整它以满足您自己的特定要求。
<Target Name="ExcludePdbFilesAfterCompile" BeforeTargets="Compile">
<ItemGroup>
<_FilteredContentWithTargetPath Include="@(ContentWithTargetPath)" Condition="'%(Extension)' == '.pdb'" />
<_FilteredContentWithTargetPath Include="@(ContentWithTargetPath)" Condition="'%(Extension)' == '.xml'" />
<ContentWithTargetPath Remove="@(_FilteredContentWithTargetPath)" />
<_FilteredReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.pdb'" />
<_FilteredReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.xml'" />
<ReferenceCopyLocalPaths Remove="@(_FilteredReferenceCopyLocalPaths)" />
</ItemGroup>
</Target>