如何为具有多个目标的 CSPROJ 生成 XML 文档 [英] How to generate XML documentation for CSPROJ with multiple targets

查看:17
本文介绍了如何为具有多个目标的 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>

如果我想要这些目标框架和 DebugRelease 配置的所有组合的 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 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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