如何防止在发布模式下复制XML文档文件? [英] How to prevent the copy of XML documentation files in a release mode build?

查看:113
本文介绍了如何防止在发布模式下复制XML文档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio 2010项目,该项目引用了一些第三方组件.它们的程序集随附有XML文档文件,这些文件对我们(仅对我们)开发人员有用.而且无论何时构建项目(在Debug或Release模式下),这些XML文件都将被复制到build目录.

I have a Visual Studio 2010 project which references some third-party components. Their assemblies are accompanied by XML documentation files, which are useful for us (and only us) developers. And whenever the project is built (either in Debug or Release modes) these XML files are copied to the build directory.

在Visual Studio中或通过MSBuild,我似乎找不到设置或切换以禁用将这些XML文件复制到构建目录的功能.生成后脚本可能是一个选择,但是很臭.有任何想法吗?谢谢.

I can't seem to find a setting or switch to disable the copy of those XML files to the build directory, either within Visual Studio or though MSBuild. A post-build script may be an option, but a smelly one. Any ideas? Thank you.

推荐答案

构建项目时,.xml/.pdb文件是通过ResolveAssemblyReference任务收集的.调用ResolveAssemblyReference时,将传递相关文件的文件扩展名列表.该文件扩展名列表在MSBuild属性 AllowedReferenceRelatedFileExtensions 中捕获.默认情况下,该列表将包含".pdb; .xml".

When you build a project the .xml/.pdb files are gathered through the ResolveAssemblyReference task. When ResolveAssemblyReference is called it is passed a list of file extensions for related files. That list of file extensions is captured in the MSBuild property AllowedReferenceRelatedFileExtensions. By default that list will contain ".pdb;.xml".

如果要排除所有相关参考文件,则只需将该属性的值覆盖为相关文件不具有扩展名的内容即可.例如,您可以将 AllowedReferenceRelatedFileExtensions 设置为-".

If you want to exclude all related reference files from being picked up then just override the value of the property to something which related files won't have extensions of. For example you can set AllowedReferenceRelatedFileExtensions to "-".

您还可以自定义返回的文件列表.如果只想查找.pdb文件,则需要传入AllowedReferenceRelatedFileExtensions=".pdb".在这种情况下,.dll/.exe旁边具有.pdb文件的所有引用也将被复制.您也可以使用它来复制其他可能不会以.pdb/.xml结尾的相关文件.例如,如果您有一个名为MyAssembly.dll的引用程序集,并且在同一文件夹中,则存在MyAssembly.pdb和MyAssembly.foo.如果设置AllowedReferenceRelatedFileExtensions=".pdb;.foo",则.pdb和.foo文件都将被复制到输出目录.

You can also customize the list of file which are returned by that. If you only want to find only .pdb files then you will need to pass in AllowedReferenceRelatedFileExtensions=".pdb". In that case any references which have .pdb file next to the .dll/.exe they will be copied as well. You can also use this to copy other related files which may not end in .pdb/.xml. For example if you have a referenced assembly named, MyAssembly.dll and in that same folder there exists MyAssembly.pdb and MyAssembly.foo If you set AllowedReferenceRelatedFileExtensions=".pdb;.foo" then both the .pdb and .foo file will be copied to the output directory.

这篇关于如何防止在发布模式下复制XML文档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆