Visual Studio bin\debug 文件夹中的 PDB 文件
我有一个 Visual Studio (2008) 解决方案,由多个项目组成,但并非全部位于同一命名空间中。 当我构建解决方案时,顶级项目 TopProject 使用的所有 DLL 文件都将复制到 TopProject\bin\debug 文件夹中。 但是,仅为某些其他项目复制相应的 .pdb 文件。 这是一种痛苦,例如在使用 NDepend 时。
Visual Studio 如何决定将哪些 .pdb 文件复制到更高级别的 bin\debug 文件夹中? 我怎样才能让 Visual Studio 也复制其他的?
参考如下:所有DLL文件都复制到一个中心位置,不包含其PDB文件。 TopProject 仅引用这些复制的 DLL 文件; 然而,DLL 文件本身显然知道它们的 PDB 文件在哪里,并且(大多数)被正确复制到 debug
文件夹中。
I have a Visual Studio (2008) solution consisting of several projects, not all in the same namespace. When I build the solution, all the DLL files used by the top level project, TopProject, are copied into the TopProject\bin\debug folder. However, the corresponding .pdb files are only copied for some of the other projects. This is a pain, for example when using NDepend.
How does Visual Studio decide which .pdb files to copy into higher level bin\debug folders? How can I get Visual Studio to copy the others too?
References are as follows: all the DLL files are copied to a central location, without their PDB files. TopProject only has references to these copied DLL files; the DLL files themselves, however, evidently know where their PDB files are, and (most of them) get copied to the debug
folder correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如其他帖子所说,您可能遇到编译器/损坏问题。
但是,正如 Will 所说,如果正在创建 PDB 文件,但没有显示在您想要的位置,请创建一个构建后步骤。 这是我为解决方案中的每个项目定义的构建后步骤。 它确保所有输出文件都复制到公共目录中。
如果您的项目文件位于 \SolutionDir\ProjDir 中,则构建后步骤的第一行会将输出文件复制到 \Solution\Bin\Release 或 \Solution\Bin\Debug。 如果这是调试版本,第二行将复制 PDB 文件。 我不会复制 PDB 文件以进行发布版本。
因此,\SolutionDir\Bin 现在将所有输出文件包含在一个位置。
As other posts have said, you may have a compiler/corruption issue.
But, as Will said, if the PDB files are being created, but not showing up where you want them, create a post-build step. Here is the post-build step I define for every project in my solution. It makes sure all output files are copied into a common directory.
If your project file is in \SolutionDir\ProjDir, then the first line of the post-build step will copy the output files to \Solution\Bin\Release or \Solution\Bin\Debug. The second line copies the PDB file if this is a debug build. I don't copy the PDB file for release builds.
So, \SolutionDir\Bin now contains all your output files in one location.
来自 MSDN:
所以看起来这里的“问题”(因为缺乏更好的词)是你的一些 DLL 是在调试模式下构建的(因此发出 PDB 文件),而有些是在发布模式下构建的(因此不发出 PDB 文件)文件)。 如果是这种情况,应该很容易修复——进入每个项目并更新其构建设置。 如果您没有对命令行选项进行任何调整,这将是默认情况。
然而,如果情况并非如此,事情就会变得更加棘手。 也许您都处于发布或调试模式。 现在您需要查看每个项目的命令行编译选项(在项目属性中指定)。 如果您需要调试器,请将它们相应地更新为 /debug,如果不需要,请将其删除。
编辑响应编辑
是的,DLL 文件“知道”它们有 PDB 文件,并且有它们的路径,但这并不意味着太多。 正如其他人提到的,仅将 DLL 文件复制到给定目录并不能解决此问题。 您还需要 PDB 文件。
在 Windows 中复制单个文件,除了某些“捆绑”类型文件(我不知道 Microsoft 的术语,但“完整的 HTML 包”是这个概念)之外,不会复制关联的文件。 DLL 文件不是以“捆绑”方式组装的,因此复制它们会留下 PDB 文件。
我想说,您将拥有的唯一答案是更新将 DLL 文件获取到这些中心位置的过程,并包含 PDB 文件……不过,我很乐意被证明是错误的!
From MSDN:
So it looks like the "issue" here (for lack of a better word) is that some of your DLLs are being built in debug mode (and hence emitting PDB files), and some are being built in release mode (hence not emitting PDB files). If that's the case, it should be easy to fix -- go into each project and update its build settings. This would be the default scenario, if you haven't done any tweaking of command line options.
However, it will get trickier if that isn't the case. Maybe you're all in release or debug mode. Now you need to look at the command line compile options (specified in the project properties) for each project. Update them to /debug accordingly if you want the debugger, or remove it if you don't.
Edit in Response to Edit
Yes, the DLL files "know" that they have PDB files, and have paths to them, but that doesn't mean too much. Copying just DLL files to a given directory, as others have mentioned, won't clear this issue up. You need the PDB files as well.
Copying individual files in Windows, with the exception of certain "bundle"-type files (I don't know Microsoft's term for this, but "complete HTML packages" are the concept) doesn't copy associated files. DLL files aren't assembled in the "bundle" way, so copying them leaves their PDB file behind.
I'd say the only answer you're going to have is to update your process for getting the DLL files to those central locations, and include the PDB files ... I'd love to be proven wrong on that, though!
首先,永远不要假设任何事情。 清理解决方案,在调试模式下重建它,然后检查是否创建了所有 PDB 文件。 如果没有,那是你的问题。
如果它们已创建,并且并未全部复制,您可以通过创建构建后事件来手动将 PDB 文件复制到所需位置来解决此问题。 当然,这只是一种解决方法。
我唯一能想到的另一件事是您的解决方案文件已损坏。 您可以将 .sln 作为 XML 文件打开并检查内容。 检查按预期运行的项目的配置,并将其与未按预期运行的项目进行比较。 如果您没有看到任何内容,则必须在项目级别重复此操作。 比较工作 .csproj (或其他)项目文件和非工作文件。
编辑响应编辑:
如果您只是手动复制内容,那么也可以手动复制 PDF 文件。 我相信 DLL 文件不应该“知道”有关 PDB 文件的任何信息。 只需将它们粘贴到目标目录中,然后去喝杯咖啡即可。 放松。
First off, never assume anything. Clean the solution, rebuild it in debug mode, and check to see if all PDB files are created. If not, that's your problem.
If they are created, and they're not all getting copied, you can get around this by creating a post build event that manually copies the PDB files to the desired locations. This is just a workaround, of course.
The only other thing I can think of is that your solution file has become corrupt. You can open your .sln as an XML file and examine the contents. Check the configuration for the projects that are acting as expected and compare them to those that aren't. If you don't see anything, you have to repeat this at the project level. Compare working .csproj (or whatever) project files and the non-working ones.
Edit in response to edit:
If you're just manually copying stuff around, then manually copy the PDF files as well. DLL files shouldn't "know" anything about PDB files, I believe. Just stick them in the destination directory and go have a cup of coffee. Relax.
清洁溶液时检查它是否确实被清洁。
我发现 Visual Studio 即使在清理后仍将文件保留在
bin\debug
目录中。 删除所有项目上的bin\debug
目录并重建。Check when you clean the solution, that it is actually cleaned.
I've seen Visual Studio leave files hanging around in
bin\debug
directories even after cleaning. Delete thebin\debug
directory on all of your projects and rebuild.