如何避免为 .Net nuget 包生成 PDB 文件?

问题描述 投票:0回答:2

我在我的项目 c# 项目中使用 CefSharp 程序集作为参考。即使在“高级构建设置”对话框中将“调试信息”设置为“无”之后,我也会在输出文件夹中为所有 CefSharp 相关文件生成 PDB 文件。

无论如何要停止在我的输出文件夹中生成它们。

nuget-package cefsharp pdb
2个回答
0
投票

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>

-1
投票

我对 cefsharp 一无所知,但对于 visual studio,我创建了这样的 nuget 包。

然后将这个包上传到nuget。我就是这么做的。希望这可以帮助您找到解决方案,至少会产生火花。

© www.soinside.com 2019 - 2024. All rights reserved.