如何为具有多个目标的 CSPROJ 生成 XML 文档

编程入门 行业动态 更新时间:2024-10-27 08:29:19
本文介绍了如何为具有多个目标的 CSPROJ 生成 XML 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个有多个目标的库项目,例如在它具有的 CSPROJ 文件中:

I have a library project that has multiple targets, e.g. in the CSPROJ file it has:

<TargetFrameworks>net40;net46;net461;net462;net47</TargetFrameworks>

如果我想要这些目标框架和 Debug 和 Release 配置的所有组合的 XML 文档,我必须使用 Build Configuration Manager 在 UI 中依次选择每一个然后将其设置为为该组合构建 XML 文档,然后每个组合在 CSPROJ 中作为 PropertyGroup 单独列出,并带有 XML 文档的预期输出文件.

If I want XML documentation for all combinations of these target frameworks and Debug and Release configurations I have to select each one in turn in the UI using the Build Configuration Manager and then set it to build XML documentation for that combination and each combination is then listed separately as a PropertyGroup in the CSPROJ with the intended output file for the XML documentation.

有没有更好的办法?

发布问题和答案,因为我没有在网上其他任何地方找到此文档

推荐答案

一个简单的方法是将 GenerateDocumentationFile 属性设置为 true.VS UI 想要设置路径,如果设置了路径,MSBuild 目标会将此属性设置为 true,如果 GenerateDocumentationFile 属性为 true,则设置默认路径.因此,您可以将其添加到您的 csproj 文件中:

An easy way is to set the GenerateDocumentationFile property to true. The VS UI want to set the path, the MSBuild targets will set this property to true if the path is set or set a default path if the GenerateDocumentationFile property is true. So you can add this to your csproj file:

<PropertyGroup> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup>

如果您想将此设置为 true 以便所有项目共享它,请创建一个名为 Directory.Build.props 在您的解决方案目录中包含以下内容,它将自动导入以下目录层次结构中的任何项目:

If you want to set this to true for all your projects to share it, create a file named Directory.Build.props in your solution's directory with the following content and it will be auto-imported into any projects in the directory hierarchy below:

<Project> <PropertyGroup> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> </Project>

更多推荐

如何为具有多个目标的 CSPROJ 生成 XML 文档

本文发布于:2023-11-05 19:30:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   何为   目标   文档   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!