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

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

问题描述

我有一个 Visual Studio 2010 项目,它引用了一些第三方组件.它们的程序集附有 XML 文档文件,这对我们(而且只有我们)开发人员很有用.并且无论何时构建项目(在调试或发布模式下)这些 XML 文件都会复制到构建目录.

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.

推荐答案

当您构建项目时,通过 ResolveAssemblyReference 任务收集 .xml/.pdb 文件.当调用 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天全站免登陆