visual-studio 如何关闭所有发布版本的 pdb 生成和 vshost

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2453841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:39:33  来源:igfitidea点击:

How to turn off pdb generation and vshost for all Release builds

.netvisual-studiovisual-studio-2008visual-studio-2012

提问by Dave Downs

Every time I start a new piece of software I have to go into the configuration and turn off pdb file generation and the Visual Studio hosting process for Release builds. Is there any way to tell Visual Studio (2008 specifically) that I want to do that for all projects for the rest of time?

每次我启动一个新软件时,我都必须进入配置并关闭 pdb 文件生成和发布版本的 Visual Studio 托管过程。有什么方法可以告诉 Visual Studio(特别是 2008)我想在剩下的时间里为所有项目这样做吗?

采纳答案by Brian Rasmussen

After some digging around, it appears that project files for C# are stored in \program files\microsoft visual studio 9.0\common7\ide\projecttemplatescache\csharp\windows\1033. By adding <UseVSHostingProcess>false</UseVSHostingProcess>to the correct sections (there are separate sections for Debug and Release configurations) of the relevant templates, you can turn off the hosting process for all future projects of the selected types.

经过一番挖掘,似乎 C# 的项目文件存储在\program files\microsoft visual studio 9.0\common7\ide\projecttemplatescache\csharp\windows\1033. 通过添加<UseVSHostingProcess>false</UseVSHostingProcess>相关模板的正确部分(调试和发布配置有单独的部分),您可以关闭所选类型的所有未来项目的托管过程。

You should be able to handle the PDB issue in a similar way, but as I said I don't recommend turning those off, so I'll leave it as an exercise :)

您应该能够以类似的方式处理 PDB 问题,但正如我所说,我不建议将其关闭,因此我将其留作练习:)

This applies to VS2008, but my guess is that other editions have a similar scheme. In fact, VS2010 uses the same approach, but obviously the version number in the directory is 10.0 instead of 9.0.

这适用于VS2008,但我猜其他版本也有类似的方案。其实VS2010也是用同样的方式,只是很明显目录中的版本号是10.0而不是9.0。

回答by Marc

In VS 2010 you will find a project property to control .pdb generation under Project Properties -> Build -> Advanced... -> Debug Info

在 VS 2010 中,您会在 Project Properties -> Build -> Advanced... -> Debug Info 下找到控制 .pdb 生成的项目属性

Set this to "none" to suppress .pdb generation.

将此设置为“无”以抑制 .pdb 生成。

回答by Stephen Kellett

Why not add a post build step that deletes these files you don't want. Hmm, that still another step, not what you wanted :-(

为什么不添加一个后期构建步骤来删除您不想要的这些文件。嗯,还有一步,不是你想要的:-(

What about writing a little helper app that does a FindFirstFile and FindNextFile loop looking for PDB and shost files in your release directories. When it finds them, it deletes them. Or better still moves them to an archive location - this allows to remove them from the release packaging issues but still keep the files in case you need them for bug analysis.

编写一个执行 FindFirstFile 和 FindNextFile 循环的小助手应用程序如何在您的发布目录中查找 PDB 和 shost 文件。当它找到它们时,它会删除它们。或者最好还是将它们移动到存档位置 - 这允许将它们从发布打包问题中删除,但仍保留文件以备您需要它们进行错误分析。

Plus because its a helper app you can just run it once as part of your pre-handoff to release staff.

另外,因为它是一个助手应用程序,您只需运行一次即可作为预交接班的一部分以释放员工。

We use this technique for lots of things:

我们将这种技术用于很多事情:

  • Ensuring DLLs are up to date (basically an intelligent update for the whole build tree)
  • Cleaning VC builds better than "batch build" can (removing some of those files that can crash Visual Studio)
  • Archiving certain in a particular fashion (similar to what I've suggested for you)
  • etc
  • 确保 DLL 是最新的(基本上是整个构建树的智能更新)
  • 清理 VC 构建比“批量构建”更好(删除一些可能导致 Visual Studio 崩溃的文件)
  • 以特定的方式存档(类似于我为您建议的)
  • 等等

I'm with Brian - you should keep these files. If you need to debug any bug or failure, you will need these files.

我和布莱恩在一起——你应该保留这些文件。如果您需要调试任何错误或故障,您将需要这些文件。